Tricky command.... - 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: Tricky command.... (
/showthread.php?tid=253069)
Tricky command.... -
[JnA]DukeNukem - 04.05.2011
Ok guys here's the deal.... I want the player (otherplayerid) that I cuffed to freeze when he gets too far away from the person who froze him (me) (playerid)
any ideas? I want that to happen automatically
Re: Tricky command.... -
Sascha - 04.05.2011
try out this:
pawn Код:
WHERE YOU CUFF THE PLAYER:
cufftime[cuffid] = SetTimerEx("CuffTimer", 1000, true, "i", cuffid); //replace the "cuffid" with the varibale the cuffed player has
WHERE YOU UNCUFF THE PLAYER:
KillTimer(cufftime[playerid]);
new cuffed[MAX_PLAYERS], control[MAX_PLAYERS], cufftime[MAX_PLAYERS];
forward CuffTimer(playerid);
public CuffTimer(playerid)
{
new pid = cuffed[playerid];
if(!IsPlayerConnected(pid))
{
SendClientMessage(playerid, 0x999999AA, "The player who cuffed you left the server, you are free.");
cuffed[playerid] = -1;
UNCUFF;
}
else
{
new Float:x, Float:y, Float:z;
GetPlayerPos(pid, x, y, z);
if(!IsPlayerInRangeOfPoint(playerid, 10.00, x, y, z) && control[playerid] == 0)
{
TogglePlayerControllable(playerid, 0);
control[playerid] = 1;
}
else
{
if(control[playerid] == 1)
{
TogglePlayerControllable(playerid, 1);
control[playerid] = 0;
}
}
}
return 1;
}
public OnPlayerConnect(playerid)
{
KillTimer(cufftime[playerid]);
return 1;
}
public OnPlayerSpawn(playerid)
{
cuffed[playerid] = -1;
control[playerid] = 0;
KillTimer(cufftime[playerid]);
return 1;
}
not checked for errors or anything else, I just wrote it up...
tell me if there are errors, etc..
Re: Tricky command.... -
[JnA]DukeNukem - 04.05.2011
Quote:
Originally Posted by Sascha
try out this:
pawn Код:
WHERE YOU CUFF THE PLAYER: cufftime[cuffid] = SetTimerEx("CuffTimer", 1000, true, "i", cuffid); //replace the "cuffid" with the varibale the cuffed player has
WHERE YOU UNCUFF THE PLAYER: KillTimer(cufftime[playerid]);
new cuffed[MAX_PLAYERS], control[MAX_PLAYERS], cufftime[MAX_PLAYERS]; forward CuffTimer(playerid); public CuffTimer(playerid) { new pid = cuffed[playerid]; if(!IsPlayerConnected(pid)) { SendClientMessage(playerid, 0x999999AA, "The player who cuffed you left the server, you are free."); cuffed[playerid] = -1; UNCUFF; } else { new Float:x, Float:y, Float:z; GetPlayerPos(pid, x, y, z); if(!IsPlayerInRangeOfPoint(playerid, 10.00, x, y, z) && control[playerid] == 0) { TogglePlayerControllable(playerid, 0); control[playerid] = 1; } else { if(control[playerid] == 1) { TogglePlayerControllable(playerid, 1); control[playerid] = 0; } } } return 1; }
public OnPlayerConnect(playerid) { KillTimer(cufftime[playerid]); return 1; }
public OnPlayerSpawn(playerid) { cuffed[playerid] = -1; control[playerid] = 0; KillTimer(cufftime[playerid]); return 1; }
not checked for errors or anything else, I just wrote it up...
tell me if there are errors, etc..
|
No errors ^^ can't really test it yet, but compiles like a dream xD
Re: Tricky command.... -
Sascha - 04.05.2011
nice to hear^^
if you'll get some errors / bugs later in-game, send me a PM (if the topic is on page X at that time ^^)