Freeze player on enter - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Freeze player on enter (
/showthread.php?tid=154713)
Freeze player on enter -
Galcio - 15.06.2010
Hey. I'm trying to make it so when you type /enter you get frozen for some seconds and then get auto-unfreezed, but it only seems to be working for ID 0. It works fine for me (id 0), but my friends stay frozen.
This is how my code looks like:
pawn Код:
forward freezeonenter();
new freezeonenterr;
if(strcmp(cmd, "/enter", true) == 0)
{
for(new i = 0; i < sizeof(Houses); i++)
{
if(PlayerToPoint(1.0,playerid,Houses[i][EnterX], Houses[i][EnterY], Houses[i][EnterZ]))
{
if(GetPlayerVirtualWorld(playerid) == Houses[i][EnterWorld])
{
if(PlayerInfo[playerid][pHouseKey] == i || Houses[i][Locked] == 0 || PlayerInfo[playerid][pAdmin] >= 1)
{
SendClientMessage(playerid, 0xAAAAAAAA, "You have been frozed, loading interior objects.");
TogglePlayerControllable(playerid, 0);
SetTimer("freezeonenter",3000,0);
SetPlayerInterior(playerid,Houses[i][ExitInterior]);
SetPlayerPos(playerid,Houses[i][ExitX],Houses[i][ExitY],Houses[i][ExitZ]);
SetPlayerVirtualWorld(playerid,i);
SetPlayerFacingAngle(playerid,Houses[i][ExitAngle]);
}
else
{
GameTextForPlayer(playerid, "~r~Locked", 5000, 1);
}
}
}
}
public freezeonenter()
{
TogglePlayerControllable(freezeonenterr, 1);
return 1;
}
Re: Freeze player on enter -
Desert - 15.06.2010
The reason for that is you want to use freezeonenterr to save players id, but you forget to save it. Therefor the ID unfreezed will always be 0 because a non-defined variable is 0.
This will also be bugged if 2 or more enters a house on the same time as then the first will not be unfreezed, so i would recommend you using SetTimerEx.
pawn Код:
forward freezeonenter();
if(strcmp(cmd, "/enter", true) == 0)
{
for(new i = 0; i < sizeof(Houses); i++)
{
if(PlayerToPoint(1.0,playerid,Houses[i][EnterX], Houses[i][EnterY], Houses[i][EnterZ]))
{
if(GetPlayerVirtualWorld(playerid) == Houses[i][EnterWorld])
{
if(PlayerInfo[playerid][pHouseKey] == i || Houses[i][Locked] == 0 || PlayerInfo[playerid][pAdmin] >= 1)
{
SendClientMessage(playerid, 0xAAAAAAAA, "You have been frozed, loading interior objects.");
TogglePlayerControllable(playerid, 0);
SetTimerEx("freezeonenter",3000,0,"playerid",playerid);
SetPlayerInterior(playerid,Houses[i][ExitInterior]);
SetPlayerPos(playerid,Houses[i][ExitX],Houses[i][ExitY],Houses[i][ExitZ]);
SetPlayerVirtualWorld(playerid,i);
SetPlayerFacingAngle(playerid,Houses[i][ExitAngle]);
}
else
{
GameTextForPlayer(playerid, "~r~Locked", 5000, 1);
}
}
}
}
public freezeonenter(playerid)
{
TogglePlayerControllable(playerid, 1);
return 1;
}
Try this instead