PDA

View Full Version : Some gs2 help...


oo_jazz_oo
03-30-2007, 02:46 AM
Ok, I am making a simple level ban system.
Now, I can add the string to the clientr.levelbans, but how do I remove a certain var from it?
So, when a staff says /ban oo_jazz_oo event_something.nw then that is added to clientr.levelbans.
When a staff says /unban oo_jazz_oo event_something.nw, how do I get that var from the clientr.levelbans and delete it?

Gambet
03-30-2007, 02:47 AM
clientr.levelbans.remove(tokens[1]); //Assuming tokens[1] == account of player

oo_jazz_oo
03-30-2007, 02:50 AM
Wont that remove the first var in the list of clientr.levelbans?
What if event_something.nw is the 4th in line? Or 20th?
I need the script to find that var in the line of vars and delete it...

Gambet
03-30-2007, 02:55 AM
Wont that remove the first var in the list of clientr.levelbans?
What if event_something.nw is the 4th in line? Or 20th?
I need the script to find that var in the line of vars and delete it...


No it doesnt remove the first "var" in the array.


It removes whatever you tell it to in the params (I.E remove(paramshere) ).

cbk1994
03-30-2007, 02:57 AM
remove() ... takes the index, doesn't it? Do something like this ...

clientr.levelbans.delete( clientr.levelbans.index( var ) );

That for sure will work, assuming you replace var with the thing you want to delete.

Gambet
03-30-2007, 03:01 AM
I still don't know what you guys don't understand about what I said x-x

remove works just fine for this

killerogue
03-30-2007, 03:53 AM
Where "tokens[1]" is, is where your parameter will go, if you tokenize the player chat before having to remove the player.

I.E.



function onPlayerChats()
{

if (player.chat.starts( "/remove" ))
{
tokens = player.chat.tokenize();
clientr.levelbans.remove(tokens[1]); //Assume this is the account of player
}
}

Rapidwolve
03-30-2007, 04:02 AM
clientr.levelbans.remove("event_something.nw");
In your case right for now, but if you have a tokens array set then use that

killerogue
03-30-2007, 04:41 AM
clientr.levelbans.remove("event_something.nw");
In your case right for now, but if you have a tokens array set then use that

No, he's trying to remove people using "/remove accountnamehere level" or "/delete accountnamehere llevel"

In which case, what I posted should work for the most part.

Rapidwolve
03-30-2007, 06:08 AM
Oh, now that changes things up. Why is he using a clientr prefix o_o

killerogue
03-30-2007, 06:38 AM
Oh, now that changes things up. Why is he using a clientr prefix o_o

I was also curious as to this, you could use a DB or server string or something. Clientr is for players bro. :P

Gambet
03-30-2007, 05:27 PM
In which case, what I posted should work for the most part.



You wrote the same thing I did -_-

xXziroXx
03-30-2007, 05:37 PM
Directly from the wiki for you doubters.


obj.delete(index)
obj.remove(obj2)

killerogue
03-30-2007, 10:12 PM
Ah, delete then.

godofwarares
03-30-2007, 10:15 PM
Simply done:


var = "godofwarares"; // An example. Var should equal your account.
clientr.levelbans.remove(clientr.levelbans.index(v ar));

Gambet
03-30-2007, 10:16 PM
Simply done:


var = "godofwarares"; // An example. Var should equal your account.
clientr.levelbans.delete(clientr.levelbans.index(v ar));




For that you use remove() -_-

Rapidwolve
03-30-2007, 10:34 PM
For that you use remove() -_-

Yes, if you want to remove a specific index its remove, and for a specific string its delete.

napo_p2p
03-30-2007, 10:36 PM
Yes, if you want to remove a specific index its remove, and for a specific string its delete.

Backwards :asleep:.

Gambet
03-30-2007, 10:41 PM
Backwards :asleep:.



^




><

xXziroXx
03-30-2007, 11:47 PM
God damnit.

delete() = DELETES an INDEX from a ARRAY
remove() = DELETES a TEXT from an ARRAY

cbk1994
03-31-2007, 12:23 AM
Okay, this will work.
Maybe it's not the most efficient, TOO BAD!

This is the tool:

function onActionServerSide( cmd, acc, level )
{
switch ( cmd )
{
case "banPlayer":
{
temp.i = findPlayer( acc );
if ( temp.i == NULL )
{
player.chat = "Player offline!";
break;
}
if ( temp.i.clientr.levelbans.index( @ level ) > -1 )
{
break;
}
temp.i.clientr.levelbans.add( level );
break;
}
case "unBanPlayer":
{
temp.i = findPlayer( acc );
if ( temp.i == NULL )
{
player.chat = "Player offline!";
break;
}
if ( temp.i.clientr.levelbans.index( @ level ) == -1 )
{
break;
}
temp.i.clientr.levelbans.delete( temp.i.clientr.levelbans.index( @ level ) );
break;
}
}
}
//#CLIENTSIDE
function onPlayerChats()
{
tokens = player.chat.tokenize();
if ( player.chat.starts( "/ban" ) ) // Say /ban account levelname
{
triggerserver( "gui", name, "banPlayer", tokens[1], tokens[2] );
}
if ( player.chat.starts( "/unban" ) ) // Say /unban account levelname
{
triggerserver( "gui", name, "unBanPlayer", tokens[1], tokens[2] );
}
}


and the code in a system script. (replace the setlevel2 with where you want it to warp the player.)

function onActionServerSide( cmd )
{
if ( cmd == "unstickPlayer" )
{
player.setlevel2( "levelname", x, y );
}
}
//#CLIENTSIDE
function onCreated()
{
testPlayer();
}
function onPlayerEnters()
{
testPlayer();
}
function testPlayer()
{
if ( clientr.levelbans.index( @ player.level.name ) > -1 )
{
player.chat = "I am banned from this level!";
triggerserver( "gui", name, "unstickPlayer" );
}
}


Hope I didnt make any errors, sorry about bad formatting.
(I used delete just because I know it works. Like to see how remove removes a text)

xXziroXx
03-31-2007, 12:24 AM
Okay, this will work.
Maybe it's not the most efficient, TOO BAD!

This is the tool:

function onActionServerSide( cmd, acc, level )
{
switch ( cmd )
{
case "banPlayer":
{
temp.i = findPlayer( acc );
if ( temp.i == NULL )
{
player.chat = "Player offline!";
break;
}
if ( temp.i.clientr.levelbans.index( @ level ) > -1 )
{
break;
}
temp.i.clientr.levelbans.add( level );
break;
}
case "unBanPlayer":
{
temp.i = findPlayer( acc );
if ( temp.i == NULL )
{
player.chat = "Player offline!";
break;
}
if ( temp.i.clientr.levelbans.index( @ level ) == -1 )
{
break;
}
temp.i.clientr.levelbans.delete( temp.i.clientr.levelbans.index( @ level ) );
break;
}
}
}
//#CLIENTSIDE
function onPlayerChats()
{
tokens = player.chat.tokenize();
if ( player.chat.starts( "/ban" ) ) // Say /ban account levelname
{
triggerserver( "gui", name, "banPlayer", tokens[1], tokens[2] );
}
if ( player.chat.starts( "/unban" ) ) // Say /unban account levelname
{
triggerserver( "gui", name, "unBanPlayer", tokens[1], tokens[2] );
}
}


and the code in a system script. (replace the setlevel2 with where you want it to warp the player.)

function onActionServerSide( cmd )
{
if ( cmd == "unstickPlayer" )
{
player.setlevel2( "levelname", x, y );
}
}
//#CLIENTSIDE
function onCreated()
{
testPlayer();
}
function onPlayerEnters()
{
testPlayer();
}
function testPlayer()
{
if ( clientr.levelbans.index( @ player.level.name ) > -1 )
{
player.chat = "I am banned from this level!";
triggerserver( "gui", name, "unstickPlayer" );
}
}


Hope I didnt make any errors, sorry about bad formatting.

You DO know that there is a /style command on RC for lazy people?

cbk1994
03-31-2007, 03:32 PM
You DO know that there is a /style command on RC for lazy people?

Yes, I do but I was unable to get to RC, and the RC's style command is really messed up.