Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Some gs2 help... (https://forums.graalonline.com/forums/showthread.php?t=73160)

oo_jazz_oo 03-30-2007 01:46 AM

Some gs2 help...
 
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 01:47 AM

PHP Code:

clientr.levelbans.remove(tokens[1]); //Assuming tokens[1] == account of player 


oo_jazz_oo 03-30-2007 01: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 01:55 AM

Quote:

Originally Posted by oo_jazz_oo (Post 1294424)
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 01:57 AM

remove() ... takes the index, doesn't it? Do something like this ...
PHP Code:

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

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

Gambet 03-30-2007 02: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 02: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.

PHP Code:


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 03:02 AM

PHP Code:

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 03:41 AM

Quote:

Originally Posted by Rapidwolve (Post 1294450)
PHP Code:

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 05:08 AM

Oh, now that changes things up. Why is he using a clientr prefix o_o

killerogue 03-30-2007 05:38 AM

Quote:

Originally Posted by Rapidwolve (Post 1294489)
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 04:27 PM

Quote:

Originally Posted by killerogue (Post 1294459)
In which case, what I posted should work for the most part.



You wrote the same thing I did -_-

xXziroXx 03-30-2007 04:37 PM

Directly from the wiki for you doubters.

PHP Code:

obj.delete(index)
obj.remove(obj2


killerogue 03-30-2007 09:12 PM

Ah, delete then.

godofwarares 03-30-2007 09:15 PM

Simply done:

PHP Code:

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


Gambet 03-30-2007 09:16 PM

Quote:

Originally Posted by godofwarares (Post 1294660)
Simply done:

PHP Code:

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




For that you use remove() -_-

Rapidwolve 03-30-2007 09:34 PM

Quote:

Originally Posted by Gambet (Post 1294661)
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 09:36 PM

Quote:

Originally Posted by Rapidwolve (Post 1294663)
Yes, if you want to remove a specific index its remove, and for a specific string its delete.

Backwards :asleep:.

Gambet 03-30-2007 09:41 PM

Quote:

Originally Posted by napo_p2p (Post 1294666)
Backwards :asleep:.



^




><

xXziroXx 03-30-2007 10:47 PM

God damnit.

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

cbk1994 03-30-2007 11:23 PM

Okay, this will work.
Maybe it's not the most efficient, TOO BAD!

This is the tool:
PHP Code:

function onActionServerSidecmdacclevel )
{
switch ( 
cmd )
{
case 
"banPlayer":
{
temp.findPlayeracc );
if ( 
temp.== NULL )
{
player.chat "Player offline!";
break;
}
if ( 
temp.i.clientr.levelbans.index( @ level ) > -)
{
break;
}
temp.i.clientr.levelbans.addlevel );
break;
}
case 
"unBanPlayer":
{
temp.findPlayeracc );
if ( 
temp.== NULL )
{
player.chat "Player offline!";
break;
}
if ( 
temp.i.clientr.levelbans.index( @ level ) == -)
{
break;
}
temp.i.clientr.levelbans.deletetemp.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.)
PHP Code:

function onActionServerSidecmd )
{
if ( 
cmd == "unstickPlayer" )
{
player.setlevel2"levelname"x);
}
}
//#CLIENTSIDE
function onCreated()
{
testPlayer();
}
function 
onPlayerEnters()
{
testPlayer();
}
function 
testPlayer()
{
if ( 
clientr.levelbans.index( @ player.level.name ) > -)
{
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-30-2007 11:24 PM

Quote:

Originally Posted by cbkbud (Post 1294738)
Okay, this will work.
Maybe it's not the most efficient, TOO BAD!

This is the tool:
PHP Code:

function onActionServerSidecmdacclevel )
{
switch ( 
cmd )
{
case 
"banPlayer":
{
temp.findPlayeracc );
if ( 
temp.== NULL )
{
player.chat "Player offline!";
break;
}
if ( 
temp.i.clientr.levelbans.index( @ level ) > -)
{
break;
}
temp.i.clientr.levelbans.addlevel );
break;
}
case 
"unBanPlayer":
{
temp.findPlayeracc );
if ( 
temp.== NULL )
{
player.chat "Player offline!";
break;
}
if ( 
temp.i.clientr.levelbans.index( @ level ) == -)
{
break;
}
temp.i.clientr.levelbans.deletetemp.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.)
PHP Code:

function onActionServerSidecmd )
{
if ( 
cmd == "unstickPlayer" )
{
player.setlevel2"levelname"x);
}
}
//#CLIENTSIDE
function onCreated()
{
testPlayer();
}
function 
onPlayerEnters()
{
testPlayer();
}
function 
testPlayer()
{
if ( 
clientr.levelbans.index( @ player.level.name ) > -)
{
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 02:32 PM

Quote:

Originally Posted by xXziroXx (Post 1294740)
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.


All times are GMT +2. The time now is 04:31 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.