SA-MP Forums Archive
Set time problem - 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: Set time problem (/showthread.php?tid=569751)



Set time problem - ZaBraNjeNi - 02.04.2015

I have a problem about setting a time.
Whats worng with this code:
Код:
CMD:setalltime(playerid,params[])
{
	if(PlayerInfo[playerid][Level] >= 4)
	{
	    if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /setalltime [hour]");
		new var = strval(params), string[128];
		
		if(var > 24) return SendClientMessage(playerid, red, "ERROR: Invalid hour");
       	CMDMessageToAdmins(playerid,"SETALLTIME");
       	
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				PlayerPlaySound(i,1057,0.0,0.0,0.0);
				SetWorldTime(var);
			}
		}
		format(string,sizeof(string),"Administrator \"%s\" has set all players time to '%d:00'", pName(playerid), var );
		return SendClientMessageToAll(blue, string);
	} else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
Thanks.


Re: Set time problem - BroZeus - 02.04.2015

Read the manual of SetWorldTime
It clearly states :
Quote:

Sets the world time (for all players) to a specific hour.

So you don't need to loop through all players
And also whats the problem? Does it send any message like "Admin "example" has setted world..."?


Re: Set time problem - ZaBraNjeNi - 02.04.2015

Server show me message like this: Administrator [NAME] has set all players time to [TIME].
But time is same.


Re: Set time problem - CalvinC - 02.04.2015

Either you have TogglePlayerClock enabled, or you have something else in our script that's setting the time.
If you have TogglePlayerClock enabled, use SetPlayerTime instead of SetWorldTime.


Re: Set time problem - ZaBraNjeNi - 02.04.2015

I haven't TooglePlayerClock and I haven't in script others codes to set time.
Problem is still.


Re: Set time problem - ZaBraNjeNi - 03.04.2015

BUMP!


Re: Set time problem - StarPeens - 03.04.2015

try it:
pawn Код:
CMD:setalltime(playerid,params[])
{
    if(PlayerInfo[playerid][Level] >= 4)
    {
        if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /setalltime [hour]");
        new var = strval(params), string[128];

        if(var > 24) return SendClientMessage(playerid, red, "ERROR: Invalid hour");
        CMDMessageToAdmins(playerid,"SETALLTIME");

        for(new playerid; playerid < MAX_PLAYERS; ++playerid)
        {
            if(IsPlayerConnected(i))
            {
                PlayerPlaySound(i,1057,0.0,0.0,0.0);
                SetWorldTime(var);
            }
        }
        format(string,sizeof(string),"Administrator \"%s\" has set all players time to '%d:00'", pName(playerid), var );
        return SendClientMessageToAll(blue, string);
    } else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}



Re: Set time problem - CalvinC - 03.04.2015

Quote:
Originally Posted by StarPeens
Посмотреть сообщение
try it:
Did you even try compiling that?
"playerid" is defined already, and you're using "i" in the functions.
The loop shouldn't be the problem.

EDIT:
Try using SetPlayerTime.
Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
	if(IsPlayerConnected(i))
	{
		PlayerPlaySound(i,1057,0.0,0.0,0.0);
		SetPlayerTime(i, var, 0);
	}
}



Re: Set time problem - StarPeens - 03.04.2015

so if its no work, he can use other script


Re: Set time problem - ZaBraNjeNi - 03.04.2015

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
Did you even try compiling that?
"playerid" is defined already, and you're using "i" in the functions.
The loop shouldn't be the problem.

EDIT:
Try using SetPlayerTime.
Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
	if(IsPlayerConnected(i))
	{
		PlayerPlaySound(i,1057,0.0,0.0,0.0);
		SetPlayerTime(i, var, 0);
	}
}
I'm already try to add something like this.
And others commands with same definitions can't work.