Tricky command....
#1

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
Reply
#2

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..
Reply
#3

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
Reply
#4

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 ^^)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)