How to check permanent account variable using query_sql?

Lord Ganja

New member
Messages
161
Points
0
Age
34
Location
Ganja World
How to check permanent account variable using query?

I wanted to check how much #PK_Points does a player have using bindatcmd but i don't know how to use query_sql

command: @checkpkpoints <player name> // Tried to create this script but I got errors xD

if ( set( .@nb, query_sql("SELECT account_id, value FROM acc_reg_num_db WHERE account_id="+getcharid(3,.@atcmd_parameters$[0])+" AND key='#PK_Points', .@aid, .@points) ) ) { if( !.@nb ) { message strcharinfo(0),"This only works on players who have PK Points"; end; } dispbottom .@points; }

Is it also possible to check if the attached <player name> is online/offline?

Like if the player is offline it will say 

 message strcharinfo(0),.@atcmd_parameter$[0]+" is offline";

Help me please. Thanks in advance!

 
Why would you need that when you can just attachrid and get variable? Or if this bindcmd is just for checking points you can use @set.

 
Why would you need that when you can just attachrid and get variable? Or if this bindcmd is just for checking points you can use @set.
LOL. I thought this was the only way.
default_hmm.gif


How to get the variable from the attached player?

Please enlighten me @@Garr.

I need it to function like:

Player1 will use '@checkpkpoints Player2' to check the #pk_points of Player2.

 
Last edited by a moderator:
Ooh, then set is not an option.

Maybe something along these lines?

- script checkpoints -1,{end;OnInit: bindatcmd "checkpkpoints",strnpcinfo(0) + "::OnCheckPoints",0,99; end;OnCheckPoints: if( .@atcmd_numparameters != 1 ) { dispbottom "Proper usage: @checkpkpoints <Player Name>"; end; } if( !(.@taid = getcharid(3,.@atcmd_parameters$)) ) { dispbottom "Requested player is not online or does not exist."; end; } .@said = getcharid(3); if( attachrid(.@taid) ) { .@points = #PK_Points; } else { dispbottom "Error occured while checking, please try again later. If this message persists contact GM."; end; } if( attachrid(.@said) ) { dispbottom "Player " + .@atcmd_parameters$ + " has " + .@points + " points."; } end;}

Please note that I did not check it ingame, and only checked for syntax mistakes using haru's script checker.

Also, I'm not really sure if bindatcmd takes every word as a separate parameter or it can take something in quotes as one parameter (and I'm too lazy to actually launch my test server/client and check it out), so this script might need a bit of fixing to work on players with spaces in names.

 
Back
Top