Set time problem
#1

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.
Reply
#2

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..."?
Reply
#3

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

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.
Reply
#5

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

BUMP!
Reply
#7

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");
}
Reply
#8

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);
	}
}
Reply
#9

so if its no work, he can use other script
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)