SA-MP Forums Archive
Clock going to 25 and higher - 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)
+--- Thread: Clock going to 25 and higher (/showthread.php?tid=398298)



Clock going to 25 and higher - stix - 08.12.2012

Ok, my server has a custom clock i made, but sometimes the weathers get bugged on certain times, and i decided to make a command which changes the world's time and sets the clock to the number i set using the settime command, but the problem is, the command can go over 24 to 25 26 and 27, when i want it to restart to 0 after 24.


pawn Код:
CMD:settime(playerid, params[])
    {
    new time;
    if(sscanf(params, "ii", time)) return SendClientMessage(playerid, GRAY, "Function : /settime [ hour ]");
    if(time < 0 || time > 24) return SendClientMessage(playerid, GRAY, "The available hours are 0-24 ! ");
    if(!sscanf(params, "ii", time))
    {
    new name[MAX_PLAYER_NAME], mestring[128];
    GetPlayerName(playerid, name, sizeof(name));
    format(mestring, sizeof(mestring), "%s has changed San Andreas Time to %d", name, time);
    SendClientMessageToAll(GRAY, mestring);
    SetWorldTime(time);
    V_ToggleClock();
    V_ToggleClock(time, 0);
    return 1;
    }
    return 1;
    }



Re: Clock going to 25 and higher - LarzI - 08.12.2012

Why do you have two i's ? I don't know why, but I feel like this is the problem, and it can be fixed by removing one of them.

DISCLAIMER: If it's supposed to be two i's cuz of some advanced shit with the latest version of sscanf, then I apologize.

Also, you don't need to do this check
pawn Код:
if(!sscanf(params, "ii", time))
when you already return if the opposite is true.


Respuesta: Clock going to 25 and higher - stix - 08.12.2012

Still not working, it goes to 25 and higher


Re: Clock going to 25 and higher - Ironboy - 08.12.2012

Try this
pawn Код:
CMD:settime(playerid,params[]) {
    if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /settime [hour]");
        new name[MAX_PLAYER_NAME], mestring[128];
        new time = strval(params);
        if(time > 24) return SendClientMessage(playerid, red, "ERROR: Invalid hour");
        for(new i = 0; i < MAX_PLAYERS; i++) {
            if(IsPlayerConnected(i)) {
                SetPlayerTime(i, time, 0);}}
        GetPlayerName(playerid, name, sizeof(name));
        format(mestring, sizeof(mestring), "%s has changed San Andreas Time to %d", name, time);
        SendClientMessageToAll(GRAY, mestring);
    return 1;}



Respuesta: Clock going to 25 and higher - stix - 08.12.2012

nvm i fixed it it was some dumb human mistake lol

max hour should be 23 to it jumps to 0 and not 24