You should style your code better, or at least make it consistent.
Here's how you should have styled it, following what you've already done.
PHP Code:
function onActionServerside(){
if (params[0] == "kick"){
if (player.account == "Imperialistic"){
temp.tokens = player.chat.tokenize();
findplayer(temp.tokens[1]).setlevel2("graalcitybank_inside_01.nw",30,30);
}
}
}
//#CLIENTSIDE
function onPlayerChats(){
if (player.chat.starts("/kick")){
triggerserver("gui",this.name,"kick");
}
}
You were doing
PHP Code:
with(findplayer(temp.tokens[1]).setlevel2("graalcitybank_inside_01.nw",30,30));
This can be shortened to
PHP Code:
findPlayer(temp.tokens[1]).setlevel2("graalcitybank_inside_01.nw",30,30);
This is because findPlayer( pl ) becomes that player.
Also, it's a good idea to use findPlayerByCommunityName( pl ) instead. Otherwise, you'll have to use the Graal####### names to kick people.
When you sent the trigger, you didn't send any params and instead tokenized the chat on the serverside part of the script. With a script like this, it's better to tokenize the player's chat and send what you need serverside, in case the players chat changes.
PHP Code:
//#CLIENTSIDE
function onPlayerChats()
{
if ( player.chat.starts( "/kick" ) )
{
temp.tokens = player.chat.tokenize();
triggerserver( "gui", name, "kick", tokens[1] );
}
}
(just put that in whatever formatting you normally use)
A few things that don't really make any difference, but can be changed:
- You don't need the temp. prefix in front of a variable if you've already defined this; see how I used that in the above example with temp.tokens.
- When sending the trigger, you don't need to use this.name. You can just use name
- You can give the 'params' names at the start of a function. Here's an example:
PHP Code:
function onActionServerSide( cmd, pl )
{
echo( "I received command" SPC cmd SPC "for" SPC pl @ "." );
if ( cmd == "kick" )
{
findPlayerByCommunityName( pl ).setlevel2( "graalcitybank)_inside_01.nw", 30, 30 );
}
}
If you don't know what echo() does, it just puts that text in RC chat.
Hope this helps you a bit, like I said, ignore my styling and use whatever you prefer. If I were to rewrite your script using what I said, it would look like this:
PHP Code:
function onActionServerSide( cmd, pl )
{
if ( cmd == "kick" )
{
findPlayerByCommunityName( pl ).setlevel2( "graalcitybank_inside_01.nw", 30, 30 );
}
}
//#CLIENTSIDE
function onPlayerChats()
{
if ( player.chat.starts( "/kick" ) )
{
temp.tokens = player.chat.tokenize();
triggerserver( "gui", name, "kick", tokens[1] );
}
}