Simple spectate system by Eros

Started by AroliS^, Jan 28, 2019, 10:43 PM

Previous topic - Next topic

AroliS^

Everything is explained on scripts.

i maked Newtimer for it but i did n't test if you want spectate system with newtimer try it but if you don't wanna just live it like that.

onScriptLoad()
spec <- false;
playerspawn
player.SpectateTarget = null;
playerClass
spec      = false;
spectate cmd
else if ( cmd == "spectate" )
{
local id = player.ID;
if ( player.Vehicle ) ::MessagePlayer( E + "You can't use this commnad using a vehicle.",player)
else if ( !text ) ::MessagePlayer(C + EROS + cmd + " <plr/off> ", player );
else if (text=="off")
{
//delete those thing & change it for newtimer(specoff)
if ( pstatus[id].spec == false )
{MessagePlayer( "You are not in spectate mode.", player );}
else if ( pstatus[id].spec == true )
{::DM( "You left specate mode.", player );}
pstatus[id].spec = false;
spec = false;
player.SpectateTarget = false;
player.IsFrozen = false;
player.Immunity = ( 0 );
//delete those thing & change it for newtimer(specoff)
}
else
{
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) ::MessagePlayer(E + "Invalid Player.", player );
else if ( plr.ID == id ) ::MessagePlayer( E + "You can not use spec on you.", player );
else if ( !plr.IsSpawned ) ::MessagePlayer( E + plr.Name + " has to choose a skin fisrt.", player );
else
{
//delete those thing & change it for newtimer(specon)
::DM(  ""+orange+"[SPEC] "+ white +" You are spectating to " + purple + plr.Name + white + " ID: " + id + " :: to exit use /spectate off",player );
player.Immunity = ( 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 16 | 32 | 64 | 128 );
pstatus[player.ID].spec = true;
spec = true;
player.SpectateTarget = plr;
//delete those thing & change it for newtimer(specon)
}
}
return 0;
}

the cmd work even without this, i added this just if you want the cmd with timer :3
Newtimers are not tested

place it on cmd
NewTimer( "specoff", 3000, 1, player.ID );
::MessagePlayer( "[#cccccc]wait 3 secs", player );
place it on function.nut
function specoff( player )
{
try
{
player = FindPlayer( player );
if ( player )
{
if ( pstatus[ player.ID ].spec == false )
{MessagePlayer( "You are not in spectate mode.", player );}
else if ( pstatus[ player.ID ].spec == true )
{::DM( "You left specate mode.", player );}
pstatus[player.ID].spec = false;
spec = false;
player.SpectateTarget = false;
player.IsFrozen = false;
player.Immunity = ( 0 );
}
}
catch(e)
MessagePlayer("error "+e,player)
}

specon function
place it on cmd
NewTimer( "specon", 3000, 1, player.ID, plr.ID );
::MessagePlayer( "[#cccccc]wait 3 secs", player );
player.IsFrozen = true;
place it on function.nut
function specon( player, plr )
{
try
{
player = FindPlayer( player );
plr = FindPlayer( plr );
if ( player )
{
if( plr )
::DM(  ""+orange+"[SPEC] "+ white +" You are spectating to " + purple + plr.Name + white + " ID: " + plr.ID + " :: to exit use /spectate off",player );
player.Immunity = ( 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 16 | 32 | 64 | 128 );
pstatus[player.ID].spec = true;
spec = true;
player.IsFrozen = true;
player.SpectateTarget = plr;
}
}
catch(e) ::MessagePlayer("error "+e,player)
}
Lemme love ya

NicusorN5

function specoff( player )
{
local player = FindPlayer( player )

No need to reinitialise the player variable since it is given as a parameter. You can try :
try{
     player.Cash += 0;
     }
     catch(e)  { //The parameter player is not an CPlayer instance. }

AroliS^

Lemme love ya

NicusorN5

Do you test your systems after you modify them?

AroliS^

I found some bugs but i fixed it up now newtimers are working great!
Lemme love ya