Jump to content
  • 0
Sign in to follow this  
Lord Ganja

How to check permanent account variable using query_sql?

Question

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!

 

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

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.

Share this post


Link to post
Share on other sites
  • 0

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. :hmm:

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.

Edited by Lord Ganja

Share this post


Link to post
Share on other sites
  • 0

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.