Command Crashes The server

Started by [VM_U]Spectra.PhantoM^, Jan 03, 2016, 07:23 AM

Previous topic - Next topic

[VM_U]Spectra.PhantoM^

Ok...... I made cops and robbers commands by my self:
else if ( cmd == "cuff" )
{
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) MessagePlayer("[Invalid Player.", player );
else
{
Message(""+ player + " Has Cuffed "+ plr + "");
plr.IsFrozen = true;
}
}

else if ( cmd == "uncuff" )
{
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) MessagePlayer("Invalid Player.", player );
else
{
Message(""+ player + " Has Un-Cuffed "+ plr + "");
plr.IsFrozen = false;
}
}

else if ( cmd == "arrest" )
{
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) MessagePlayer("Invalid Player.", player );
if ( plr.IsFrozen == false ) MessagePlayer("That Player Is Either Not Cuffed Or He Isnt Wanted", player);
else
{
Message(""+ player + " Has Arrested "+ plr + "");
plr.Pos = Vector(391.039, -506.887, 9.39561 );
plr.IsFrozen = true;
}
}

Its all working well till i add the line:
if ( player.pos = plr.pos == false) MessagePlayer(" you need to be close to "+plr+"to cuff him/her.",player);when i add this line the whole server crashes....
Any help plz.
Wanna Talk To Me? Come At Irc #Jugo@LUNet

Mashreq

The reason why your server crashes is it is Pos not pos and even if you change this to Pos it won't be going to work because player.Pos returns a vector and it will not be going to match with true/false statement.

So you can use this one:
if ( DistanceFromPoint( player.Pos.x, player.Pos.y, plr.Pos.x, plr.Pos.y ) <= 5 ) MessagePlayer( "You are near to " + plr.Name, player );
else MessagePlayer( "You need to be close to " + plr.Name + " to cuff him/her", player );

I've used a distance of 5, you can change it to the distance what you need.

[VM_U]Spectra.PhantoM^

#2
it says an error
...... ill post an image of error wait....
Wanna Talk To Me? Come At Irc #Jugo@LUNet

EK.IceFlake

Setting a statement doesn't return true/false
"if (player.pos = plr.pos == false)"

Williams

@{ultimatejugo] try this :

else if ( cmd == "arrest" )
{
if ( text )
{
local plr = FindPlayer( text );
if(plr)
{
if(GetPlayerDistance(player,plr) <= 3)
{
if ( plr.IsFrozen == false )
{
Message(""+ player + " Has Arrested "+ plr + "");
plr.Pos = Vector(391.039, -506.887, 9.39561 );
plr.IsFrozen = true;
}
else MessagePlayer("That Player Is Either Not Cuffed Or He Isnt Wanted", player);
}
else MessagePlayer ( "You need to be close to "+plr.Name+" to arrest him.", player );
}
else MessagePlayer ( "Error - Unknown player", player );
}
else MessagePlayer( "usage : /arrest  <Nick/ID>",player );
}

Thanks @Mashreq for giving idea :D :P
Hey, i m always at IRC and Forum you can comtact me at IRC channel :- #GDM @LUNet and Forum :- http://pro-fighter.tk/index.php

Anik

Quote from: Williams on Jan 05, 2016, 10:58 AM@{ultimatejugo] try this :

else if ( cmd == "arrest" )
{
if ( text )
{
local plr = FindPlayer( text );
if(plr)
{
if(GetPlayerDistance(player,plr) <= 3)
{
if ( plr.IsFrozen == false )
{
Message(""+ player + " Has Arrested "+ plr + "");
plr.Pos = Vector(391.039, -506.887, 9.39561 );
plr.IsFrozen = true;
}
else MessagePlayer("That Player Is Either Not Cuffed Or He Isnt Wanted", player);
}
else MessagePlayer ( "You need to be close to "+plr.Name+" to arrest him.", player );
}
else MessagePlayer ( "Error - Unknown player", player );
}
else MessagePlayer( "usage : /arrest  <Nick/ID>",player );
}

Thanks @Mashreq for giving idea :D :P
He is making /cuff and /uncuff cmd not /arrest -_-

Williams

@Anik he making cops and robbers command...!and  he also help in arrest command !

else if ( cmd == "arrest" )
{
if (( player.Skin == 1 ) || ( player.Skin == 3 ) || ( player.Skin == 4 ))
{
if ( text )
{
local plr = FindPlayer( text );
if(plr)
{
if(GetPlayerDistance(player,plr) <= 3)
{
if ( plr.IsFrozen == false )
{
Message(""+ player + " Has Arrested "+ plr + "");
plr.Pos = Vector(391.039, -506.887, 9.39561 );
plr.IsFrozen = true;
}
else MessagePlayer("That Player Is Either Not Cuffed Or He Isnt Wanted", player);
}
else MessagePlayer ( "You need to be close to "+plr.Name+" to arrest him.", player );
}
else MessagePlayer ( "Error - Unknown player", player );
}
else MessagePlayer( "usage : /arrest  <Nick/ID>",player );
}
else MessagePlayer ( "You must be a part of police to arrest someone", player );
}

else if ( cmd == "cuff" )
{
if (( player.Skin == 1 ) || ( player.Skin == 3 ) || ( player.Skin == 4 ))
{
if ( text )
{
local plr = FindPlayer( text );
if(plr)
{
if(GetPlayerDistance(player,plr) <= 3)
{
Message(""+ player + " Has Cuffed "+ plr + "");
plr.IsFrozen = true;
}
else MessagePlayer ( "You need to be close to "+plr.Name+" to cuff him.", player );
}
else MessagePlayer ( "Error - Unknown player", player );
}
else MessagePlayer( "usage : /cuff  <Nick/ID>",player );
}
else MessagePlayer ( "You must be a part of police to arrest someone", player );
}

else if ( cmd == "uncuff" )
{
if (( player.Skin == 1 ) || ( player.Skin == 3 ) || ( player.Skin == 4 ))
{
if ( text )
{
local plr = FindPlayer( text );
if(plr)
{
if(GetPlayerDistance(player,plr) <= 3)
{
Message(""+ player + " Has Un-Cuffed "+ plr + "");
plr.IsFrozen = false;
}
else MessagePlayer ( "You need to be close to "+plr.Name+" to uncuff him.", player );
}
else MessagePlayer ( "Error - Unknown player", player );
}
else MessagePlayer( "usage : /uncuff  <Nick/ID>",player );
}
else MessagePlayer ( "You must be a part of police to arrest someone", player );
}

Try that @{ultimatejugo] hope it's work !
Hey, i m always at IRC and Forum you can comtact me at IRC channel :- #GDM @LUNet and Forum :- http://pro-fighter.tk/index.php