when I spawn and spend time spawnkill inserted console "stopped working and closes automatically"
function onScriptLoad()
{
AntiSP <- array( GetMaxPlayers(), null );
}
function onPlayerSpawn( player )
{
SP( player );
}
function onPlayerHealthChange( player, oldhp, newhp )
{
if ( AntiSP[ player.ID ] == true )
{
player.Health = 100;
}
}
function onPlayerKill( killer, player, reason, bodypart )
{
if ( AntiSP[ player.ID ] == true )
{
killer.Health = 0;
PrivMessage( "Spawn-Kill not allowed!", killer );
MessageAllExcept( "** Auto-kill:[ " + killer.Name + " ]. Reason:[ Spawn-Kill ]", killer );
}
}
function SP( player )
{
AntiSP[ player.ID ] = true;
NewTimer( "SPoff", 5000, 1, player );
PrivMessage( "Anti Spawn-Kill:[ ON ]", player );
}
function SPoff( player )
{
AntiSP[ player.ID ] = false;
PrivMessage( "Anti Spawn-Kill:[ OFF ]", player );
}
Change
function SP( player )
{
AntiSP[ player.ID ] = true;
NewTimer( "SPoff", 5000, 1, player );
PrivMessage( "Anti Spawn-Kill:[ ON ]", player );
}
function SPoff( player )
{
AntiSP[ player.ID ] = false;
PrivMessage( "Anti Spawn-Kill:[ OFF ]", player );
}
to
function SP( player )
{
AntiSP[ player.ID ] = true;
NewTimer( "SPoff", 5000, 1, player.ID );
PrivMessage( "Anti Spawn-Kill:[ ON ]", player );
}
function SPoff( p )
{
local player = FindPlayer(p);
if(player){
AntiSP[ player.ID ] = false;
PrivMessage( "Anti Spawn-Kill:[ OFF ]", player );
}
}
this has been already discussed that we can not pass player INSTANCE through Timer thats why your server crashes
Thank
You can do an anti spawnkill system without timers too, which is better
Quote from: hotdogcat on Nov 28, 2015, 03:51 PMYou can do an anti spawnkill system without timers too, which is better
How? I only had this way to do my spawn-kill system.
Can you tell me an example on "How to do SP thing without timer"?
As I do hotdogcat?
There is an Example (http://vcmp.liberty-unleashed.co.uk/forum/index.php?topic=818.msg4639#msg4639) of antispawn without timer in old forum that is made by
@Gudio
Don't copy paste that script since it wouldn't work for 0.4: IDs start with 0, not 1.
Quote from: Kusanagi on Nov 28, 2015, 08:35 PMThere is an Example (http://vcmp.liberty-unleashed.co.uk/forum/index.php?topic=818.msg4639#msg4639) of antispawn without timer in old forum that is made by @Gudio
Yet, Timers are not bad unless they are used badly.
But thanks for giving that, you gave me a new idea.
And also, I use many extra things like alpha, immunity etc
Quote from: Thijn on Nov 28, 2015, 09:07 PMDon't copy paste that script since it wouldn't work for 0.4: IDs start with 0, not 1.
Yea
You can use this:
function onScriptLoad()
{
AntiSP <- array( GetMaxPlayers(), 0 );
NewTimer( "Timers", 1000, 0 );
}
function Timers()//You can avail this timer. Example: mute, heal, goto, gotoloc.
{
for( local i = 0, player; i < GetMaxPlayers(); i++ )
{
player = FindPlayer( i );
if ( player )
{
if ( AntiSP[ player.ID ] >= 1 )
{
AntiSP[ player.ID ] --;
if ( AntiSP[ player.ID ] == 0 ) PrivMessage( player, "Anti Spawn-Kill:[ OFF ]" );
}
}
}
}
function onPlayerHealthChange( player, lastHP, newHP )
{
if ( newHP < 100 && AntiSP[ player.ID ] >= 1 ) player.Health = 100;
}
function onPlayerSpawn( player )
{
AntiSP[ player.ID ] = 5;
PrivMessage( player, "Anti Spawn-Kill:[ ON ]" );
}
function onPlayerKill( killer, player, reason, bodypart )
{
if ( AntiSP[ player.ID ] >= 1 )
{
if ( killer.Vehicle ) killer.Eject();
killer.Health = 0;
PrivMessage( killer, "Spawn-Kill not allowed!" );
MessageAllExcept( "** Auto-kill:[ " + killer.Name + " ]. Reason:[ Spawn-Kill ]", killer );
}
}
Thanks Diego but there is an error (https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi68.tinypic.com%2F2r6pgtj.png&hash=30f008097df02ac7b80ae2a4f16ce7184fbfbbee)
Here works correctly, it must be something wrong in your script.
The error is pretty clear, you forgot to add the Timers function.
As I add?
Quote from: wilber32 on Dec 01, 2015, 01:24 PMAs I add?
As I care?
You mean you didn't add the function, then how the F*ck are you expecting it to work?
Kindly, add the function or ....
if you add the function and its not works Then
It can be caused of if you add the timer in the top of onscriptload add it after the dofiles