Couple questions about creating new characters

Here you can post threads requesting help on the official POL Ultima Online Emulator Core 096.
Note: Core 096 is no longer officially supported.

Moderator: POL Developer

Post Reply
User avatar
Datus
Apprentice Poster
Posts: 58
Joined: Tue Sep 19, 2006 6:27 am

Couple questions about creating new characters

Post by Datus »

Is it possible to remove the Advanced option on the class selection menu? It's not in the prof file ...

Also... how do I restrict how many characters are allowed per account?

Thanks.
Yukiko
Distro Developer
Posts: 2825
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Post by Yukiko »

This might be what you need to limit characters.

In \pol\scripts\misc in oncreate.src after the following code:

Code: Select all

    syslog("ALERT! Account " + account.name + " was banned for cheating.");
  endif
add this:

Code: Select all

  var maxchars := 5; // Maximum allowed characters.
  var numchars := 0; // Counter for use later
    for i := 1 to 5 
        var chr := account.GetCharacter(i); 
        if (!chr) 
            continue; 
        else
            numchars := numchars + 1;
        endif 
    endfor
    
    if (numchars > maxchars)
        who.paralyzed :=1;
        SendSysMessage(who, "You have exceeded the maximum allowable characters!!!", 2, 33);
        SendSysMessage(who, "In 30 seconds this character will be deleted.", 2, 33);
        Sleep(30);
        DisconnectClient( victim );
        account.DeleteCharacter( i );
    endif
The only caveat is that the character must be in a safe logout (insta log) location when she enters the world for the account.DeleteCharacter to operate correctly. If she is in a delayed logout condition then the account.DeleteCharacter doesn't work or atleast it didn't in POL 95.

I think that scriptlet will work.

NOTE: This is is compatible with a converted POL 0.95 scripset only.
Barbeirosa

Post by Barbeirosa »

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. :oops:
User avatar
Datus
Apprentice Poster
Posts: 58
Joined: Tue Sep 19, 2006 6:27 am

Post by Datus »

barb,

Now I could be wrong here but I believe the "who.paralyzed :=1; " part means the character is now paralyzed and cannot "go running off to play".

Besides, anyone who goes running off to play on my shard gets killed instantly ... it's part of the magic.

Anyway this script looks good to me and if nothing more gives me something to work with.

Thanks Yukiko
Barbeirosa

Post by Barbeirosa »

Datus wrote:barb,

Now I could be wrong here but I believe the "who.paralyzed :=1; " part means the character is now paralyzed and cannot "go running off to play".
Granted. But maybe read beyond the first sentence or two, mkay? Or have fun dealing with players who get their 7xGM character deleted because of the above script.
User avatar
Datus
Apprentice Poster
Posts: 58
Joined: Tue Sep 19, 2006 6:27 am

Post by Datus »

Ok I'm convinced now that Barbeirosa is a joke... so I'm going to ignore him... unless he does a really amazing trick ... like actually post his own code.
Barbeirosa

Post by Barbeirosa »

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: Select all

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)
User avatar
Datus
Apprentice Poster
Posts: 58
Joined: Tue Sep 19, 2006 6:27 am

Post by Datus »

that's pretty crappy barbie...

you just copied 90% of what yukiko already wrote... and you can prove me wrong by not being a weenie.
Barbeirosa

Post by Barbeirosa »

Datus wrote:that's pretty crappy barbie...

you just copied 90% of what yukiko already wrote...
Except I fixed the numerous errors which would have had your players pretty pissed. Crappy? Fine. I already said I won't do it again. Next time, just use whatever you find!
Yukiko
Distro Developer
Posts: 2825
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Post by Yukiko »

A couple of things:

1. I made that post as my lappy battery was getting low so I was afraid I'd lose power and didn't have time to script a gump call. Hence the message being in RED and being set to font 2, an expanded larger font than the default font.

2. I mentioned the caveat about needing an insta log location for character creation because I assumed that most shard owners chose the location the character enters the world. If they don't know how to do that then please ask and I am sure Barbarosa can explain it to them.

Barbarosa wrote:
Better yet, make the message a GUMP, so they can't miss it. But then kick them out immediately...
3. Wouldn't kicking the player immediately after sending a gump disconnect them and therefore prevent them from seeing it? I haven't checked that out yet but it might not give the desired result.

I do agree that a non closable gump would be the ideal way of informing the player but as I said I was up against the clock that night. By the way I did miss seeing that gump code in your "new and improved" version of my scriptlet Barbie.

As for any other criticisms of my code...
Barbeirosa

Post by Barbeirosa »

Yukiko wrote: 3. Wouldn't kicking the player immediately after sending a gump disconnect them and therefore prevent them from seeing it? I haven't checked that out yet but it might not give the desired result.
Yes it would, which is why I put in a one-second sleep after.

Your code gave a great basic idea how to do what was asked but the problem is a lot of the time people just cut and paste exactly what is posted without ever looking at it. Your original post almost seemed to suggest doing exactly that. But as far as offering help for the general idea it was great and as dattie said I basically copied it for my own post.


As for the other topic in this thread; you can't really remove the advanced option but you can sort of hide it. Just add more entries to the prof.txt file to push the advanced option out of the way. 6 entries pushes it down. The result is not pretty but it may work for you.
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Re: Couple questions about creating new characters

Post by gundamwing84 »

will this script work on pol 97? and if it does, is there a way to change it so that it doesnt delete the character, just kicks them from the game when they log into one of them?
Tomi
POL Developer
Posts: 478
Joined: Tue Feb 21, 2006 5:08 pm

Re: Couple questions about creating new characters

Post by Tomi »

Another solution should be to hook the 0x00 packet ( Character Creation ) and stop the char creation even before it has been created.
That way thee should be no need for any checks as you mentioned above.
Justae
Expert Poster
Posts: 79
Joined: Thu May 24, 2007 2:12 pm
Location: South Africa

Re: Couple questions about creating new characters

Post by Justae »

From the changelog.txt, I put the bold highlights in.

12-14 Nando:
Fixed: Characters/Starting Location packet wasn't sending the correct characters number. This
was causing problems when enabling the 6th & 7th slot (or limiting to 1 slot). Characters
number will now be set to Max(CharacterSlot, 5). The number of CharacterSlots shown will
depend on the acct expansion. (If it´s more than AOS, it'll send > 6, else 5).
Added: Flags in the Characters/Starting Location packet and the Enable Features (0xB9) are
now being set according to the CharacterSlots option in pol.cfg. It only works now
with 1, 5, 6 and 7 slots, as this is a client limitation. You can hook the 0xB9 packet
to change this in the future.

Nice code snippet, Yukkiko, despite other comments. It's a foundation for those who are willing to learn POL and study the changelog.txt and eScript documentation.

Cheers,
Justae.
Post Reply