BuLaLaKaW Posted February 8, 2014 Posted February 8, 2014 Hi! Requesting help on how to implement these lines. 1. Check the player account id who is online on a specific map on the char sql table. Main goal is to get the value of @acct_id (single and multiple results) set @last_map$, "prontera"; query_sql "SELECT account_id FROM char WHERE last_map = "+@last_map$+" AND online = 1",@acct_id; 2. Update last location of a character Main goal is to update char sql table and make sure last_map is updated in this command set @char_id, strcharinfo(0); set @last_map$, "prontera"; query_sql "UPDATE char SET last_map = "+@last_map$+" WHERE char_id = "+@char_id+""; Thanks Quote
-SkittleNugget- Posted February 9, 2014 Posted February 9, 2014 What script do you want to add this to? Quote
Missingno Posted February 9, 2014 Posted February 9, 2014 set @last_map$, "prontera"; query_sql "SELECT account_id FROM char WHERE last_map = "+@last_map$+" AND online = 1",@acct_id; You'd probably be better of using a temporary NPC variable (.@last_map$), since it doesn't seem like you'll need that data exclusive to the attached player; same goes for where you're storing the account IDs (.@acct_id). set @char_id, strcharinfo(0); set @last_map$, "prontera"; query_sql "UPDATE char SET last_map = "+@last_map$+" WHERE char_id = "+@char_id+""; This will cause your script to error, as you're trying to store a string (strcharinfo(0), which will return the player's name as a string) as a numerical value for @char_id (again, probably better off as a temporary NPC variable, .@char_id); from what I gather, you intend to retrieve the player's character ID, which can be done with getcharid(0). Additionally, your SQL query will fail, because the table char needs to be enclosed in backticks (`char`); char is a reserved keyword and will not execute correctly if not enclosed properly. In regards to your script, it just seems like you're trying to force-update a player's last map, which may actually be overwritten when the char-server saves again. o_o Quote
Patskie Posted February 9, 2014 Posted February 9, 2014 set .@last_map$, "prontera"; query_sql "SELECT DISTINCT(`account_id`) FROM `char` WHERE `last_map` = '" +escape_sql(.@last_map$)+ "' AND `online` = '1'",.@acct_id; /* Single Result */ mes "Account ID : " +.@acct_id; /* Multiple Results */ for ( .@i = 0; .@i < getarraysize(.@acct_id); .@i++ ) mes "Account ID : " +.@acct_id[.@i]; ----------------------------------------------------------------------------------------------------------- set .@char_id, getcharid(0); set .@last_map$, "prontera"; query_sql "UPDATE `char` SET `last_map` = '" +escape_sql(.@last_map$)+ "' WHERE `char_id` = '" +.@char_id+ "'"; Quote
Question
BuLaLaKaW
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.