SA-MP Forums Archive
Wrong with my /setweather command - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Wrong with my /setweather command (/showthread.php?tid=254955)



Wrong with my /setweather command - BizzyD - 13.05.2011

Hello, I got a problem with my /setweather command, When i do /setweather 5 for an example, It dosent set the weather that i want. It just gives a random number. But if i do /setweather 1. It changes to the weather id 1.

This is my cmd:

pawn Код:
CMD:setweather(playerid,params[])
    {
        new string[128];
        new sendername[MAX_PLAYER_NAME];
        new weather;
        if(sscanf(params, "u[32]", weather))
        return SendClientMessage(playerid, RED, "[LOST:RP] /setweather [Weather ID]");
        if(PlayerInfo[playerid][pAdmin] < 4)
        return SendClientMessage(playerid, RED, "[LOST:RP] You are not high admin enough");
        {
            SetWeather(weather);
            SendClientMessage(playerid, RED, "[LOST:RP] The weather has been changed");
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, 256, "[LOST:RP] [ADMIN] %s has changed the weather to %d.", sendername,weather);
            aMessage(COLOR_YELLOW,string,1);
        }
        return 1;
    }
Anyone know how to fix?

Regards, alex


Re: Wrong with my /setweather command - MadeMan - 13.05.2011

pawn Код:
if(sscanf(params, "d", weather))



Re: Wrong with my /setweather command - BizzyD - 13.05.2011

Ahh okey, Thank you. I am still new to SSCANF


Re: Wrong with my /setweather command - Laronic - 13.05.2011

Only use "s[STRING_LENGHT]" if it is a string.

Код:
The format codes are:
 
	c - A character.
	d, i - An integer.
	h, x - A hex number (e.g. a colour).
	f - A float.
	s - A string.
	z - An optional string.
	pX - An additional delimiter where X is another character.
	'' - Encloses a litteral string to locate.
	u - User, takes a name, part of a name or an id and returns the id if they're connected.
sscanf

Hope it helped


Re: Wrong with my /setweather command - kvsolga - 13.05.2011

Try that if you want it in "strcmp"

Код:
}
if (!strcmp("/setweather", cmdtext, true))
{
        new string[128];
        new sendername[MAX_PLAYER_NAME];
        new weather;
        if(sscanf(params, "d", weather))
        return SendClientMessage(playerid, RED, "[LOST:RP] /setweather [Weather ID]");
        if(PlayerInfo[playerid][pAdmin] < 4)
        return SendClientMessage(playerid, RED, "[LOST:RP] You are not high admin enough");
        {
            SetWeather(weather);
            SendClientMessage(playerid, RED, "[LOST:RP] The weather has been changed");
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, 256, "[LOST:RP] [ADMIN] %s has changed the weather to %d.", sendername,weather);
            aMessage(COLOR_YELLOW,string,1);
        }
        return 1;
    }



Re: Wrong with my /setweather command - __ - 13.05.2011

That won't even work kvsolga.

Furthermore:
pawn Код:
new weather = strval(params);



Re: Wrong with my /setweather command - SchurmanCQC - 13.05.2011

Quote:
Originally Posted by __
Посмотреть сообщение
That won't even work kvsolga.

Furthermore:
pawn Код:
new weather = strval(params);
Thats exactly what I use when I make ZCMD/DCMD commands with only one parameter; I recommend this.


Re: Wrong with my /setweather command - Ozz - 13.05.2011

you muste to uset "d" in sscanf pal.
note "u" -.-


Re: Wrong with my /setweather command - BizzyD - 13.05.2011

I am new to SSCANF :P

@kvsolga

I dont want it in STRCMP :P Because i rather use ZCMD + SSCANF