{SHU}ALEXM16

Script Question, ranking

19 posts in this topic

Database
ALTER TABLE `account` ADD `rank` INT(2) UNSIGNED NULL DEFAULT NULL;

exile.ini

[getrank]
SQL1_1 = SELECT rank FROM account WHERE uid = ?
Number Of Inputs = 1
SQL1_INPUTS = 1
OUTPUT = 1

mpmission:
rank.sqf
private["_playerUID","_rank"];
_playerUID = getPlayerUID;
_rank =getrank

if (_rank ="1") then {
	[] execVM "rank\spawnr1.sqf";
};

if (_rank ="2") then {
	[] execVM "rank\spawnr2.sqf";
};

What do you guys think?

any changes? any errors? thanks for the help?

Edited by {SHU}ALEXM16
  • Like 1

Share this post


Link to post
Share on other sites
Advertisement

Hello Alex,

 

Remember what I said, BACKUP THE DB FIRST!

 

You can do it via the export function OR if you have actual access to the system, just copy the actual DB files themselves.  Either will work!

VERIFY that which ever you used, is USABLE/READABLE BEFORE RUNNING SCRIPT!  Remember: "Trust, But Verify"

Hope it works for ya!

 

:)

 

  • Like 1

Share this post


Link to post
Share on other sites
3 hours ago, Metalman10 said:

wish i could help but looks good to me..but that could mean anything lol

Totally looks good. Didn't even notice that the call for extDB isn't even in there, missing semi colons, you can't run getPlayerUID on nothing, and "=" is not how you check to see something is equal. Aren't you the kid who keeps telling people he is a developer? That's like me telling people I'm a medical doctor because I can put a band-aid on a cut. 

 

Anywho, @{SHU}ALEXM16
"rank.sqf" is wrong as that it won't work. It needs to run from the server in order to use extDB functionality. You'd probably want to run this from onPlayerConnected or ExileServer_object_player_createBambi / ExileServer_object_player_database_load.


"getPlayerUID" requires a object to get the uid from, however, since you are running this on the server, "player" cannot be used. You will need to either get the UID passed into this script, make use of Exile's network messages and get the player object from the sessionID, or do the arma way and pass this script the netID of the player so you can convert it into an object. 


Your extDB call needs to be formatted so extDB can understand it. Using what your call requires, it would be:

format["getRank:%1",_playerUID] call ExileServer_system_database_query_selectSingleField;

 

"=" is not a way of comparing things in programming languages. It basically means, this equals that. For comparing, the == boolean operator is what you would use. However, in ArmA, it's safer to use "isEqualTo" as that "==" does not handle objects and such. You could nest your if statements if you wanted to, but that should be fine. 

if (_rank isEqualTo "1") then 
{
	[] execVM "rank\spawnr1.sqf";
};

if (_rank isEqualTo "2") then 
{
	[] execVM "rank\spawnr2.sqf";
};

As for figuring out how to put all of that together into a workable script, that is dependent on when that needs to be ran. 

  • Like 1

Share this post


Link to post
Share on other sites

could use a switch case as opposed to if/else too, since you're only comparing the value of one variable.:P 

  • Like 2

Share this post


Link to post
Share on other sites
56 minutes ago, Z80CPU said:

Hello Alex,

 

Remember what I said, BACKUP THE DB FIRST!

 

You can do it via the export function OR if you have actual access to the system, just copy the actual DB files themselves.  Either will work!

VERIFY that which ever you used, is USABLE/READABLE BEFORE RUNNING SCRIPT!  Remember: "Trust, But Verify"

Hope it works for ya!

 

:)

 

I have dumps been made every 15minutes so not the problem but thanks for taking care of me, and my db. :-)

 

1 hour ago, WolfkillArcadia said:

Totally looks good. Didn't even notice that the call for extDB isn't even in there, missing semi colons, you can't run getPlayerUID on nothing, and "=" is not how you check to see something is equal. Aren't you the kid who keeps telling people he is a developer? That's like me telling people I'm a medical doctor because I can put a band-aid on a cut. 

 

Anywho, @{SHU}ALEXM16
"rank.sqf" is wrong as that it won't work. It needs to run from the server in order to use extDB functionality. You'd probably want to run this from onPlayerConnected or ExileServer_object_player_createBambi / ExileServer_object_player_database_load.


"getPlayerUID" requires a object to get the uid from, however, since you are running this on the server, "player" cannot be used. You will need to either get the UID passed into this script, make use of Exile's network messages and get the player object from the sessionID, or do the arma way and pass this script the netID of the player so you can convert it into an object. 


Your extDB call needs to be formatted so extDB can understand it. Using what your call requires, it would be:


format["getRank:%1",_playerUID] call ExileServer_system_database_query_selectSingleField;

 

"=" is not a way of comparing things in programming languages. It basically means, this equals that. For comparing, the == boolean operator is what you would use. However, in ArmA, it's safer to use "isEqualTo" as that "==" does not handle objects and such. You could nest your if statements if you wanted to, but that should be fine. 


if (_rank isEqualTo "1") then 
{
	[] execVM "rank\spawnr1.sqf";
};

if (_rank isEqualTo "2") then 
{
	[] execVM "rank\spawnr2.sqf";
};

As for figuring out how to put all of that together into a workable script, that is dependent on when that needs to be ran. 

allot of information for my little brain to process, let me read it a few times and get back with you, probably with questions thanks :-)

 

Share this post


Link to post
Share on other sites

Hello Alex,

 

You're more than welcome!  You would be surprised how many people will not make a backup till they need it.  Also, as a IT tech for 30+ years, you would be surprised at how many techs did make backups, BUT NEVER TESTED THEM!  They found out the hard way when they tried to use them...and well..then came the tears...and the hiding from the customer...  ;)

 

I would just hate to see all your hard work go to waste!

 

As before, I hope it goes well!

:)

 

 

  • Like 1

Share this post


Link to post
Share on other sites
14 minutes ago, Metalman10 said:

@WolfkillArcadia well yea i do tell people that, but saying that doesnt mean i know everything in the world. I know enough to do whatever i gotta do. You would be surprised on how much people know little to nothing. But again just trying to help. Is that a issue? 

I think it becomes an issue when you're telling someone their code "looks good" when in fact it's full of errors. Rather than guessing and masking it under the guise of "helping", try not to spread misinformation; it hinders learning and gives us all a bad name.

  • Like 1

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.