SA-MP Forums Archive
problem with jail timer - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: problem with jail timer (/showthread.php?tid=595127)



problem with jail timer - Ernests - 28.11.2015

Hello, I have a big problem with jail system. I have a server where player can be jailed for some time. Everything works, this jail timer works fine until
Quote:

else if(GetPVarInt(i, "Jail") == 1)

where server should say "Unjailed". But server says nothing and player stays in the same position (SetPlayerPos don't work)! But the biggest mistery of this script for me is that function
Quote:

SetPVarInt(i, "Jail", GetPVarInt(i, "Jail")-1);

works... I'm not so good in pawno, anyne can help me explaining why player do not get teleported and server message do not show, but SetPVarIn works fine?

Код:
else if(GetPVarInt(i, "Jail") == 1)
		{
		SetPlayerHealth(i, 100);
       			SetPlayerPos(i, 621.689453125, -596.9580078125, 16.731489181519);
       			SendClientMessage(i, COLOR_GREEN, "SERVER: Unjailed!");
		format(file, 128, "/Accounts/%s.ini", GetName(i));
       			SetPVarInt(i, "Jail", GetPVarInt(i, "Jail")-1);
		}



Re: problem with jail timer - ATGOggy - 28.11.2015

pawn Код:
else if(GetPVarInt(i, "Jail") == 1)
        {
        SetPlayerHealth(i, 100);
                SetPlayerPos(i, 621.689453125, -596.9580078125, 16.731489181519);
                SendClientMessage(i, COLOR_GREEN, "SERVER: Unjailed!");
        format(file, 128, "/Accounts/%s.ini", GetName(i));
                SetPVarInt(i, "Jail", GetPVarInt(i, "Jail")-1);
                        printf("hello");
        }
See if it prints hello.


Re: problem with jail timer - Ernests - 28.11.2015

It doesn't!

EDIT: Fixed!


Re: problem with jail timer - PrO.GameR - 28.11.2015

SetPVarInt(i, "Jail", GetPVarInt(i, "Jail")-1);
GetPVarInt returns 0 if there is no such variable, therefore first time you set it, it sets Jail to -1, and -1 is not ==1
Simply when jailing do this SetPVarInt(i, "Jail", 1);
when taking him out of jail
DeletePVar(i, "jail");