A question about changing Miliseconds to minutes. -
Thunderbolt - 02.01.2012
Hello,
I have scripted my " Admin's system " jail command, and I want to use Minutes instead of Miliseconds like
instead of doing
/jail playerid 15000 hi.
do:
/jail playerid 15 hi.
Oh and change the timers to Minutes not Miliseconds.
My script is:
pawn Код:
YCMD:jail(playerid, params[])
{
if(PlayerInfo[playerid][Admin] == 1)
{
new JailedPlayer, string[128], thetime, reason[126];
if(sscanf(params, "uis[126]", JailedPlayer, thetime, reason)) return SCM(playerid, COLOR_GREY, "YCMD: /jail [Part of Name/Player ID] [Time] [Reason]");
PlayerInfo[JailedPlayer][Jail] = 1;
PlayerInfo[JailedPlayer][JailedTime] = thetime;
SetPlayerPos(JailedPlayer, 250.56483459473, 1868.0897216797, -30.752481460571);
SetTimerEx("JailedTimer", thetime, false,"i",JailedPlayer);
format(string, sizeof(string), "%s has jailed you for about %i, Reason: %s.", PlayerName(playerid), thetime, reason);
SCM(JailedPlayer, COLOR_YELLOW, string);
format(string, sizeof(string), "Admin: %s has jailed %s for %i.", PlayerName(playerid), PlayerName(playerid), PlayerInfo[JailedPlayer][JailedTime]);
AMessage(COLOR_LIGHTRED, string);
} else return SCM(playerid, COLOR_GREY, "You're not authorized to use this command.");
return 1;
}
Re: A question about changing Miliseconds to minutes. -
PawnoQ - 02.01.2012
pawn Код:
SetTimerEx("JailedTimer", thetime*60000, false,"i",JailedPlayer);
To prevent issues u should also check the time variable and return a msg invalid time value if its negative or too big etc.
Re: A question about changing Miliseconds to minutes. -
Thunderbolt - 02.01.2012
Thank you, I'll try to do like you posted. And, sorry but what do you mean by " check the time variable and return a message "? Where do I do that?
Re: A question about changing Miliseconds to minutes. -
BlackWolf120 - 02.01.2012
mhh, im not sure but i think he meant to check if the time the player entered is in a range you want it to be.
As there could occur bugs if a player enters a negative time value, strings, floats or whatever.
To prevent this just do smth. like this: (this is just an example you have to adjust it to ur needs ofc.)
pawn Код:
if(thetime<1)return SendClientMessage(playerid,0xFF0000FF,"The JailTime must be at least 1 minute!");
Hope this helps
Re: A question about changing Miliseconds to minutes. -
Thunderbolt - 02.01.2012
O thank you BlackWolf ^^.