SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 02/01/2012, 08:13 PM   #1
Thunderbolt
Little Clucker
 
Thunderbolt's Avatar
 
Join Date: Jan 2012
Location: I'd love to live in the U.S.
Posts: 32
Reputation: 3
Flowers A question about changing Miliseconds to minutes.

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 Code:
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;
}
Thunderbolt is offline   Reply With Quote
Old 02/01/2012, 08:21 PM   #2
PawnoQ
Huge Clucker
 
Join Date: Nov 2011
Posts: 375
Reputation: 7
Default Re: A question about changing Miliseconds to minutes.

pawn Code:
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.
PawnoQ is offline   Reply With Quote
Old 02/01/2012, 08:27 PM   #3
Thunderbolt
Little Clucker
 
Thunderbolt's Avatar
 
Join Date: Jan 2012
Location: I'd love to live in the U.S.
Posts: 32
Reputation: 3
Default Re: A question about changing Miliseconds to minutes.

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?
Thunderbolt is offline   Reply With Quote
Old 02/01/2012, 08:35 PM   #4
BlackWolf120
Gangsta
 
BlackWolf120's Avatar
 
Join Date: Nov 2010
Location: Germany
Posts: 761
Reputation: 50
Default Re: A question about changing Miliseconds to minutes.

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 Code:
if(thetime<1)return SendClientMessage(playerid,0xFF0000FF,"The JailTime must be at least 1 minute!");

Hope this helps
__________________
BlackWolf120 is offline   Reply With Quote
Old 02/01/2012, 09:02 PM   #5
Thunderbolt
Little Clucker
 
Thunderbolt's Avatar
 
Join Date: Jan 2012
Location: I'd love to live in the U.S.
Posts: 32
Reputation: 3
Default Re: A question about changing Miliseconds to minutes.

O thank you BlackWolf ^^.
Thunderbolt is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert miliseconds to regular time? sciman001 Help Archive 4 05/05/2011 12:26 AM
Minutes, seconds, miliseconds MP2 Help Archive 9 24/02/2011 03:43 AM
How to make an automatic gate that closes after 4 minutes and 2 minutes after re justinkomnuga Help Archive 4 06/04/2010 12:47 PM


All times are GMT. The time now is 05:27 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.