Player Immunity/Spawn Protection

Started by umar4911, Oct 16, 2017, 11:17 AM

Previous topic - Next topic

umar4911

I was making spawn protection.
I added this onplayerspawn

player.Immunity = 31;
MessagePlayer("Spawn Protection Enabled", player);
NewTimer("visibility", 5000, 1, player.ID);


Function
function visibility(player)
{
player.Immunity = 0;
MessagePlayer("Spawn Protection Disabled", player);
}

Error
An error has occured[trying to set in integer]
I am gamer, programmer and hacker. Try to find me!
xD

KAKAN

NewTimer("visibility", 5000, 1, player.ID);
You're passing player.ID and automagically expecting it to become 'player' instance.
function visibility(player)
{
 player.Immunity = 0;
 MessagePlayer("Spawn Protection Disabled", player);
}
They all are player's IDs, not instances. So, your code is doing: 0.Immunity = 0; MsgPlr( "", 0 );
oh no

umar4911

Quote from: KAKAN on Oct 16, 2017, 11:46 AMNewTimer("visibility", 5000, 1, player.ID);
You're passing player.ID and automagically expecting it to become 'player' instance.
function visibility(player)
{
 player.Immunity = 0;
 MessagePlayer("Spawn Protection Disabled", player);
}
They all are player's IDs, not instances. So, your code is doing: 0.Immunity = 0; MsgPlr( "", 0 );
Oh yeah..
I used
NewTimer("visibility", 5000, 1, player);
but now it shuts my server "Server.exe has stopped working"
I am gamer, programmer and hacker. Try to find me!
xD

!

Timer doesn't send instance use player.ID(integer) instead of player(instance).
NewTimer("visibility", 5000, 1, player.ID);

and this in function.
local player = FindPlayer(playerID);

Like this
function visibility(playerID)
{
   local player = FindPlayer(playerID);
   if ( !player ) return;
   player.Immunity = 0;
   MessagePlayer("Spawn Protection Disabled", player);
}

Discord: zeus#5155

umar4911

I am gamer, programmer and hacker. Try to find me!
xD