Question about PVars and timerex.
#1

When player logs out, if the player has a timer on or a PVar, it will stop automatically? or i'll have to killtimer
Reply
#2

You could avoid such situations simply by turning them off when player disconnect
A timer for example
pawn Код:
forward Timer(playerid);
public Timer(playerid)
{
if(!IsPlayerConnected(playerid))return KillTimer(YourTimer);
}
For PVars i think they get set to false when player disconnects but anyways you could use
pawn Код:
public OnPlayerDisconnect(playerid)
{
SetPVarInt(playerid, "MyVar", 0);
//.......
Reply
#3

PVars are reseted on disconnect, timers are not. Even though you have passed the player id to the timer as a parameter, it considers it just as a normal integer.
Reply
#4

Use y_timer's ptask, it will start/stop on connection/disconnect.

In regards to PVars, they will reset on disconnect. However, the example DaRk_RaiN gave is wrong. You're wasting memory by keeping the PVar if you aren't going to use it- just use DeletePVar().
Reply
#5

One more question:

I got this code:

Код:
public OnPlayerSpawn(playerid)
{
	if(GetIntVar(playerid, "gLogged") != 1)
	{
		KickEx(playerid, "[SERVER]: You must be logged in to spawn!");
	}
	if(GetIntVar(playerid, "JustDied") == 1)
	{
		PutPlayer(playerid, PlayerInfo[playerid][pPosX],PlayerInfo[playerid][pPosY],PlayerInfo[playerid][pPosZ]);
		ClearAnimations(playerid);
		ApplyAnimation(playerid, "CRACK", "crckdeth1", 4.0, 1, 0, 0, 0, 0); // Dieing of Crack
		return 1;
	}
	return 1;
}
It's doesn't apply the animation on the player..
Reply
#6

Animations are tricky. There are a few different pieces of code around here, but you basically need to load the animation libraries before you can have synced animations. Search the function "PreloadAnimLib" or something like that- it should return some good results.
Reply
#7

Okay I've fixed it, added onPlayerDeath
PreloadPlayerAnims(playerid);
which I have found on the internet
Reply
#8

Why when I freeze the player, his animations are stopped.

i've seen server when the players dies, he got freezed and still in animation.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)