SA-MP Forums Archive
How would i do this? - 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: How would i do this? (/showthread.php?tid=140357)



How would i do this? - Torran - 08.04.2010

How would i start a timer for the amount of time the person typed in after the command?

So like: SetTimerEx("Bla", params, 0, "i", playerid);

Like that, How would i do it correctly?


Re: How would i do this? - biltong - 08.04.2010

Do you want it in minutes or seconds, because timers use milliseconds. If you want seconds, multiply the input by 1000, if you want minutes, multiply by 60000. Remember to use strval for params.


Re: How would i do this? - Torran - 08.04.2010

Quote:
Originally Posted by biltong
Do you want it in minutes or seconds, because timers use milliseconds. If you want seconds, multiply the input by 1000, if you want minutes, multiply by 60000. Remember to use strval for params.
I want it in miliseconds,
still dosent answer my question though,

How would i set a timer for the time the player puts after the command?


Re: How would i do this? - biltong - 08.04.2010

new time = strval(params);
SetTimerEx("bla", time, 0, "i", playerid);

Should work.


Re: How would i do this? - Torran - 08.04.2010

I dont use strval cause i cant the way im doing it but it sitll works the same,
Anyway thats not working - btw i using sscanf


Re: How would i do this? - biltong - 08.04.2010

Quote:
Originally Posted by Joe Torran C
I dont use strval cause i cant the way im doing it but it sitll works the same,
Anyway thats not working - btw i using sscanf
0o


new time;
if(sscanf(params, "i", time)) return SendClientMessage(playerid, 0xFFFFFFFF, "You didn't specify a time!");
else SetTimerEx("bla", time, 0, "i", playerid);

If that doesn't work, I don't know what will.


Re: How would i do this? - Torran - 08.04.2010

Quote:
Originally Posted by biltong
Quote:
Originally Posted by Joe Torran C
I dont use strval cause i cant the way im doing it but it sitll works the same,
Anyway thats not working - btw i using sscanf
0o


new time;
if(sscanf(params, "i", time)) return SendClientMessage(playerid, 0xFFFFFFFF, "You didn't specify a time!");
else SetTimerEx("bla", time, 0, "i", playerid);

If that doesn't work, I don't know what will.
1. Yeah that dosent work..
2. Anyone else know?


Re: How would i do this? - dice7 - 08.04.2010

Maybe showing the code, so we can see what you're doing wrong ?


Re: How would i do this? - Torran - 08.04.2010

pawn Код:
CMD:jail(playerid, params[])
{
    new id, time, reason[128];
    new string[128];
    if(!(BaseInfo[playerid][AdminLevel] > 1)) return SendClientMessage(playerid, COLOR_RED, "You are not an administrator with the required level");
    if(sscanf(params, "uiz", id, time, reason)) return SendClientMessage(playerid, COLOR_RED, "Usage: /jail [PlayerID/PartOfName] [Time] [Reason]");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Player not Found");
    if(id == playerid) return SendClientMessage(playerid, COLOR_RED, "Cannot jail Yourself");
    if(BaseInfo[id][AdminLevel] > 4) return SendClientMessage(playerid, COLOR_RED, "Cannot jail the Highest Level Admin");
   
    if(!reason[0]) {
        format(string, sizeof string, "Administrator %s has jailed %s for %i miliseconds", GetPlayersName(playerid), GetPlayersName(id), time);
        SendClientMessageToAll(COLOR_BLUE, string);

        SetTimerEx("Unjail", time, 0, "i", playerid);
        JailPlayer(id);
        return BaseInfo[id][Jailed] = 1;
    }
   
    format(string, sizeof string, "Administrator %s has jailed %s for %i miliseconds with reason: %s", GetPlayersName(playerid), GetPlayersName(id), time, reason);
    SendClientMessageToAll(COLOR_BLUE, string);

  SetTimerEx("Unjail", time, 0, "i", playerid);
    BaseInfo[id][Jailed] = 1;
    JailPlayer(id);
    return 1;
}



Re: How would i do this? - dice7 - 08.04.2010

You're trying to unjail 'playerid' (which typed the command) instead of 'id' (which got jailed)