BuLaLaKaW Posted February 8, 2014 Group: Members Topic Count: 19 Topics Per Day: 0.00 Content Count: 125 Reputation: 7 Joined: 11/19/11 Last Seen: August 20, 2021 Share 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 Link to comment Share on other sites More sharing options...
-SkittleNugget- Posted February 9, 2014 Group: Members Topic Count: 11 Topics Per Day: 0.00 Content Count: 318 Reputation: 54 Joined: 12/23/12 Last Seen: July 1, 2017 Share Posted February 9, 2014 What script do you want to add this to? Quote Link to comment Share on other sites More sharing options...
Missingno Posted February 9, 2014 Group: Members Topic Count: 7 Topics Per Day: 0.00 Content Count: 135 Reputation: 41 Joined: 02/05/14 Last Seen: December 23, 2022 Share 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 Link to comment Share on other sites More sharing options...
Patskie Posted February 9, 2014 Group: Members Topic Count: 50 Topics Per Day: 0.01 Content Count: 1702 Reputation: 241 Joined: 09/05/12 Last Seen: 5 hours ago Share 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 Link to comment Share on other sites More sharing options...
Question
BuLaLaKaW
Link to comment
Share on other sites
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.