23.03.2011, 19:09
Can someone give me a example like /setweather, /setallweather, /sethp (health) please, Zcmd and sscanf
CMD:setweather( playerid, params[ ] )
{
new Player, Weather;
if ( sscanf( params, "ui", Player, Weather ) ) return SendClientMessage( playerid, 0x20FF20FF, "USAGE: /setweather "GREY"<id> <weather id>");
else
{
if ( Player == ( 0xFFFF ) ) return SendClientMessage( playerid, 0xFF2020FF, "Player not connected!");
SetPlayerWeather( Player, Weather );
new Str[ 256 ];
if ( Player != playerid )
{
format( Str, sizeof (Str), "You set %s's weather to %d", Name( Player ), Weather );
SendClientMessage( playerid, 0xC3C3C3FF, Str );
format( Str, sizeof (Str), "Admin %s set your weather to %d", Name( playerid), Weather );
SendClientMessage( Player, 0xC3C3C3FF, Str );
}
else
{
format( Str, sizeof (Str), "You set your weather to %d", Weather );
SendClientMessage( playerid, 0xC3C3C3FF, Str );
}
}
return 1;
}
pawn Код:
|
CMD:setweatherall(playerid, params[]) {
if(!isnull(params)) {
return SendClientMessage(playerid, -1, "Usage: /setweatherall [weatherid]");
} else {
new
szMessage[32],
iWeather = strval(params);
if(iWeather < 1 || iWeather > 45){
format(szMessage, sizeof(szMessage), "%d is not a valid weather ID.", iWeather);
return SendClientMessage(playerid, -1, szMessage);
}
format(szMessage, sizeof(szMessage), "Weather changed to ID: #%d.", iWeather);
SendClientMessage(playerid, -1, szMessage);
SetWeather(iWeather);
}
return 1;
}
CMD:setallweather( playerid, params[ ] )
{
new Weather;
if ( sscanf( params, "i", Weather ) ) return SendClientMessage( playerid, 0x20FF20FF, "USAGE: /setallweather {C3C3C3}<weather id>");
else
{
for ( new p = 0; p < MAX_PLAYERS; ++p )
{
if ( IsPlayerConnected( p ) )
{
SetPlayerWeather( p, Weather );
}
}
new Str[ 256 ];
format( Str, sizeof (Str), "Admin %s everyone's weather to %d", Name( playerid), Weather );
SendClientMessageToAll( 0xC3C3C3FF, Str );
}
return 1;
}