Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: wilber32 on Nov 27, 2015, 11:09 PM

Title: error in spawnkill
Post by: wilber32 on Nov 27, 2015, 11:09 PM
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 );
}
Title: Re: error in spawnkill
Post by: MacTavish on Nov 28, 2015, 12:44 AM
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
Title: Re: error in spawnkill
Post by: wilber32 on Nov 28, 2015, 11:34 AM
Thank
Title: Re: error in spawnkill
Post by: hotdogcat on Nov 28, 2015, 03:51 PM
You can do an anti spawnkill system without timers too, which is better
Title: Re: error in spawnkill
Post by: KAKAN on Nov 28, 2015, 06:05 PM
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"?
Title: Re: error in spawnkill
Post by: wilber32 on Nov 28, 2015, 06:25 PM
As I do hotdogcat?
Title: Re: error in spawnkill
Post by: MacTavish on Nov 28, 2015, 08:35 PM
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
Title: Re: error in spawnkill
Post by: Thijn on Nov 28, 2015, 09:07 PM
Don't copy paste that script since it wouldn't work for 0.4: IDs start with 0, not 1.
Title: Re: error in spawnkill
Post by: KAKAN on Nov 29, 2015, 04:43 AM
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
Title: Re: error in spawnkill
Post by: Diego^ on Nov 30, 2015, 09:39 PM
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 );
}
}



Title: Re: error in spawnkill
Post by: wilber32 on Dec 01, 2015, 01:06 AM
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)
Title: Re: error in spawnkill
Post by: Diego^ on Dec 01, 2015, 01:43 AM
Here works correctly, it must be something wrong in your script.
Title: Re: error in spawnkill
Post by: Thijn on Dec 01, 2015, 06:38 AM
The error is pretty clear, you forgot to add the Timers function.
Title: Re: error in spawnkill
Post by: wilber32 on Dec 01, 2015, 01:24 PM
As I add?
Title: Re: error in spawnkill
Post by: KAKAN on Dec 01, 2015, 03:25 PM
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 ....
Title: Re: error in spawnkill
Post by: Cool on Dec 06, 2015, 02:17 PM
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