 |
 |
 |
 |
|
 |
 |
|
 |
 |
| Author |
Message |
Barbeirosa
Joined: 01 Feb 2007 Posts: 43
|
Posted: Fri Mar 02, 2007 6:58 am Post subject: |
|
|
I hope anyone who uses that script as written is ready for some big-time nightmares.
Let's first assume that characters won't be created in a "insta-log" area. But even if we don't assume that, the script there gives the character plenty of time to run to such a place. Most people completely ignore login messages, so I guarantee they'll usually miss that message, and go running off to play, and find themselves kicked off for reasons they don't understand.
Maybe, after it happens a couple times, they'll realize why. They'll be confused about why their character isn't actually being deleted, though. So, maybe they'll log in one of their real characters to check it. They'll see that SAME MESSAGE. And they won't know this... but if they don't run that character RIGHT AWAY away from a zero-timeout location, it will be THAT character that will be deleted.
*sigh*
First problem: They should be logged off immediately when this happens... not have it wait 30 seconds. Put in a sleep of a second to assure they get the message. Better yet, make the message a GUMP, so they can't miss it. But then kick them out immediately, and MARK THE CHARACTER with a CProp to note that it must be deleted. The 30-second sleep is a decent idea - but AFTER kicking them off and marking them with a CProp. Not before.
When counting characters in this script, then, you must also check for this CProp, and ONLY count characters that don't have this CProp. If anyone ever logs in a char with this CProp, just kick and delete, without even bothering counting. Otherwise, count ONLY those without the CProp, and...
Finally, after you kick them off, for heaven's sake, don't leave things up to chance!!! Move their character to a zero-timeout location first!
Whoever wrote the above script needs some logic lessons before any more scripting lessons, I think.  |
|
 |
|
|
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
| Author |
Message |
Barbeirosa
Joined: 01 Feb 2007 Posts: 43
|
Posted: Sat Mar 03, 2007 3:28 am Post subject: |
|
|
This is the only time I will do this, and only to prove you wrong. I told you how to do it, it should have been a simple matter to figure out. But here it is. Next time, I'm sure you'll be able to figure it out yourself.
| Code: |
var account := who.acct;
var INVALID_CHAR_CPROP := "INVALID_CHARACTER";
var maxchars := 5;
var numchars := 0;
var myindex := 0;
if (GetObjProperty(who, INVALID_CHAR_CPROP))
numchars := maxchars + 1;
endif
var i;
for (i:=1;i<=5;i:=i+1)
var chr := account.GetCharacter(i);
if (chr)
if (!GetObjProperty(chr, INVALID_CHAR_CPROP))
numchars := numchars + 1;
endif
if (chr==who)
myindex := i;
endif
endif
endfor
if (numchars > maxchars && myindex)
who.paralyzed :=1;
SendSysMessage(who, "You have exceeded the maximum allowable characters ("+cstr(maxchars)+") This character will be deleted.", FONT_BOLD, FONTCOLOR_RED);
Sleep(1);
SetObjProperty(who, INVALID_CHAR_CPROP, 1);
var x, y, z; //set x, y, z to a closed 'insta-log' location
MoveCharacterToLocation(who, x, y, z, MOVECHAR_FORCELOCATION);
DisconnectClient(who);
sleep(30);
account.DeleteCharacter(myindex);
endif
|
If there are any typos in the code, feel free to ask about them. I did not bother mentioning the typos in the code I fixed that would have resulted in other errors (like, always deleting the 5th character, no matter which character was actually the one logged on) |
|
 |
|
|
 |
 |
|
 |
 |
|
|