Euphy Posted June 9, 2012 Group: Members Topic Count: 72 Topics Per Day: 0.02 Content Count: 2997 Reputation: 1132 Joined: 05/27/12 Last Seen: June 1, 2017 Share Posted June 9, 2012 If it isn't too much work, it'd be useful to have a few more character commands that work regardless of online/offline status. It's both annoying and inefficient (script-wise) to keep checking whether to attachrid or do an SQL query, since attachrid doesn't work for offline characters (obviously) and SQL queries don't update immediately for online characters. And when setting character/account variables, there's the additional check whether to do an SQL update or insertion. Altogether it'd just be a lot more convenient to have these commands, or something similar: Like setd, set a character or account variable for a specified character/account ID. This would work without attachrid(), and regardless of online/offline status. The variable prefix should automatically determine whether the supplied ID is character or account.* setc <character ID>,"<variable name>",<value>; * setc <account ID>,"<variable name>",<value>; Like getd, and same as above.* getc(<character ID>,"<variable name>") * getc(<account ID>,"<variable name>") Also, extend rid2name() and getcharid() to work for offline characters. Opinions? 7 Quote Link to comment Share on other sites More sharing options...
Brian Posted June 9, 2012 Group: Members Topic Count: 75 Topics Per Day: 0.02 Content Count: 2223 Reputation: 593 Joined: 10/26/11 Last Seen: June 2, 2018 Share Posted June 9, 2012 I think these would be very useful! But would it require more char-server code too? because character saving happens at the char-server level. Quote Link to comment Share on other sites More sharing options...
Omnipotent Posted June 10, 2012 Group: Members Topic Count: 1 Topics Per Day: 0.00 Content Count: 71 Reputation: 25 Joined: 11/23/11 Last Seen: May 16, 2024 Share Posted June 10, 2012 getcharid is some of the ways to know if a character is online or not, it would make problems with some scripts. Quote Link to comment Share on other sites More sharing options...
Euphy Posted June 10, 2012 Group: Members Topic Count: 72 Topics Per Day: 0.02 Content Count: 2997 Reputation: 1132 Joined: 05/27/12 Last Seen: June 1, 2017 Author Share Posted June 10, 2012 @Omnipotent: That's what we have this command for. *isloggedin(<account id>{,<char id>}) (I'm aware a few people used getcharid() to check online status, but that shouldn't be the reason offline implementation is held back.) 1 Quote Link to comment Share on other sites More sharing options...
Nameless2you Posted June 11, 2012 Group: Members Topic Count: 14 Topics Per Day: 0.00 Content Count: 351 Reputation: 52 Joined: 11/15/11 Last Seen: June 15, 2015 Share Posted June 11, 2012 I support this. Quote Link to comment Share on other sites More sharing options...
xazax Posted June 14, 2012 Group: Members Topic Count: 11 Topics Per Day: 0.00 Content Count: 427 Reputation: 123 Joined: 11/17/11 Last Seen: December 31, 2022 Share Posted June 14, 2012 Since we dropped TXT, I think it is not too hard to make it possible to modify offline player's variables, or read them. In fact, you can already do that with query_sql, however built in support would be much more elegant of course. Quote Link to comment Share on other sites More sharing options...
Euphy Posted June 14, 2012 Group: Members Topic Count: 72 Topics Per Day: 0.02 Content Count: 2997 Reputation: 1132 Joined: 05/27/12 Last Seen: June 1, 2017 Author Share Posted June 14, 2012 @xazax: The problem with doing SQL queries is that variables aren't updated right away. There's always some delay, and from what I've tested it ranges anywhere from a few seconds to minutes. I didn't realize we had an "@set" command, though. Wouldn't at least half the code for these commands be identical to the atcommand? Quote Link to comment Share on other sites More sharing options...
KeyWorld Posted June 14, 2012 Group: Members Topic Count: 9 Topics Per Day: 0.00 Content Count: 379 Reputation: 304 Joined: 11/10/11 Last Seen: December 2, 2014 Share Posted June 14, 2012 getcharid is some of the ways to know if a character is online or not, it would make problems with some scripts. They should use playerattached(). In memory getcharid() throw an error if no player attached to the scriptNo opinion about an offline mode. Quote Link to comment Share on other sites More sharing options...
Omnipotent Posted June 19, 2012 Group: Members Topic Count: 1 Topics Per Day: 0.00 Content Count: 71 Reputation: 25 Joined: 11/23/11 Last Seen: May 16, 2024 Share Posted June 19, 2012 (edited) I'm supporting this too, I just wanted to mark out that detail. @KeyWorld: But I mean getting the status, and if he's connected the id of a character who is not attached at that moment to the script. >if(getcharid(0,"john")) he's online, so attachrid and stuff. @Euphy: I'm agree on this, only was a detail for some old scripts, but the change required is minimal. Edited June 19, 2012 by Omnipotent Quote Link to comment Share on other sites More sharing options...
sketchyphoenix Posted June 20, 2012 Group: Members Topic Count: 6 Topics Per Day: 0.00 Content Count: 112 Reputation: 89 Joined: 11/12/11 Last Seen: April 5 Share Posted June 20, 2012 (edited) I like the idea. I want to start working on it after work today. I'm probably going to make it so if the command is used and the offline character is actually online, it will switch to the regular set routines. It'll be like a safer version of set. Also, I don't think character ID and account ID as an parameter in the same command would be a feasible idea. A sufficiently large enough character database could have IDs that are the same numbers as the account IDs, and that would mess up the logic. I would probably have to separate those into separate commands. Edited June 20, 2012 by sketchyphoenix 2 Quote Link to comment Share on other sites More sharing options...
Euphy Posted June 20, 2012 Group: Members Topic Count: 72 Topics Per Day: 0.02 Content Count: 2997 Reputation: 1132 Joined: 05/27/12 Last Seen: June 1, 2017 Author Share Posted June 20, 2012 You're amazing. Thank you~ Couldn't you only use one command, though? Because variable types are defined by prefixes, can't you read the variable type first before processing the ID? I really don't know C at all, so correct me if I'm wrong. Quote Link to comment Share on other sites More sharing options...
sketchyphoenix Posted June 20, 2012 Group: Members Topic Count: 6 Topics Per Day: 0.00 Content Count: 112 Reputation: 89 Joined: 11/12/11 Last Seen: April 5 Share Posted June 20, 2012 The problem is that only the parser in the script engine recognizes variable affixes and once it leaves the txt file and goes into memory, those get stripped from the variable name before being stored..if i remember correctly. If not, then oh well. That's no impact on anything, I still have to set aside several commands to differentiate between char ID and account ID - and if the server is assuming these players are offline, it can't assume that the calling NPC has a player attached, so it needs that information beforehand. So I'll need 4 commands. One that alters an entry for a character variable.. One that alters an entry for an account variable. And 2 more to retrieve those. If the character or account is logged in, then the command will simply act as set would, instead of altering the database directly. 1 Quote Link to comment Share on other sites More sharing options...
Euphy Posted June 20, 2012 Group: Members Topic Count: 72 Topics Per Day: 0.02 Content Count: 2997 Reputation: 1132 Joined: 05/27/12 Last Seen: June 1, 2017 Author Share Posted June 20, 2012 Alright, that makes sense. At least it'll prevent any confusion. Thanks a lot. c: Quote Link to comment Share on other sites More sharing options...
Sneaky Posted June 20, 2012 Group: Members Topic Count: 10 Topics Per Day: 0.00 Content Count: 392 Reputation: 47 Joined: 11/18/11 Last Seen: July 8, 2024 Share Posted June 20, 2012 +1 great idea. Quote Link to comment Share on other sites More sharing options...
Ind Posted June 20, 2012 Group: Members Topic Count: 169 Topics Per Day: 0.03 Content Count: 1260 Reputation: 750 Joined: 11/19/11 Last Seen: April 11, 2013 Share Posted June 20, 2012 The problem is that only the parser in the script engine recognizes variable affixes and once it leaves the txt file and goes into memory, those get stripped from the variable name before being stored..if i remember correctly. you should be able to identify both smoothly without the need of another 2 commands imo, you can take a look on script.c::set_reg() for reference Quote Link to comment Share on other sites More sharing options...
GreenBox Posted June 22, 2012 Group: Members Topic Count: 9 Topics Per Day: 0.00 Content Count: 303 Reputation: 101 Joined: 11/13/11 Last Seen: October 11, 2023 Share Posted June 22, 2012 This can slow down the script VM(mainly for getc), the script execution will need to be suspended and wait a response from char-server, so this command should be used wisely. Quote Link to comment Share on other sites More sharing options...
sketchyphoenix Posted June 25, 2012 Group: Members Topic Count: 6 Topics Per Day: 0.00 Content Count: 112 Reputation: 89 Joined: 11/12/11 Last Seen: April 5 Share Posted June 25, 2012 Finally started on it today. Saving is done. Loading in progress. 1 Quote Link to comment Share on other sites More sharing options...
Zell Posted May 9, 2015 Group: Members Topic Count: 53 Topics Per Day: 0.01 Content Count: 412 Reputation: 266 Joined: 04/25/12 Last Seen: Yesterday at 01:17 AM Share Posted May 9, 2015 (edited) This was updated? I tried to make a getcharvariable but I have problem with the sql delay to save on global reg. @edit Never mind, i maked this with script https://rathena.org/board/topic/101748-function-getcharvar/ Edited May 9, 2015 by Zell Quote Link to comment Share on other sites More sharing options...
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.