CMD:slap(playerid,params[])
{
new string[128], playerb, height;
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playerb][pAdmin]) return SendClientMessage(playerid, COLOR_GREY, "Player has a higher admin level than you.");
if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /slap [playerid] [height]");
new Float:pos[3];
GetPlayerPos(playerb,pos[0],pos[1],pos[2]);
SetPlayerPos(playerb,pos[0],pos[1],pos[2]+height);
format(string,sizeof(string),"AdmWarn: %s has slapped %s(%d)", RPN(playerid), RPN(playerid), height);
SendAdminMessage(COLOR_LIGHTRED, 1, string);
return 1;
}
if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /slap [playerid] [height]");
|
You're missing a sscanf specifier.
pawn Код:
|
if(sscanf(params, "ui", playerb,height)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /slap [playerid] [height]");
|
Additionally you could always do this.... if(height <= 0) height = 10.0; so it will always set a default even if a height is not specified or negative.
Sound as well.... PlayerPlaySound(playerb, 1130, 0.0, 0.0, 10.0); |
|
Or, make the height an OPTIONAL specifier and default the value to whatever you want.
|
CMD:slap(playerid,params[])
{
new string[128], playerb, height;
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playerb][pAdmin]) return SendClientMessage(playerid, COLOR_GREY, "Player has a higher admin level than you.");
if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /slap [playerid] [height]");
sscanf(params, "uf", playerb, height);
if(playerb == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /slap [playerid] [height]");
if(height <= 0.0) height = 10.0;
new Float:pos[3];
GetPlayerPos(playerb,pos[0],pos[1],pos[2]);
SetPlayerPos(playerb,pos[0],pos[1],pos[2]+height);
format(string,sizeof(string),"AdmWarn: %s has slapped %s(%d)", RPN(playerid), RPN(playerid), height);
SendAdminMessage(COLOR_LIGHTRED, 1, string);
return 1;
}
CMD:slap(playerid,params[])
{
new string[128], playerb, height;
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on Admin Duty.");
if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playerb][pAdmin]) return SendClientMessage(playerid, COLOR_GREY, "Player has a higher admin level than you.");
if(sscanf(params, "ui", playerb,height)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /slap [playerid] [meters]");
if(height < 100) return SendClientMessage(playerid, COLOR_GREY, "You can not slap anyone over 100 meters.");
new Float:pos[3];
GetPlayerPos(playerb, pos[0], pos[1], pos[2]);
SetPlayerPos(playerb, pos[0], pos[1], pos[2]+height);
//if(height < 0 || height > 100) return SendClientMessage(playerid, COLOR_GREY, "You can not slap anyone over 100.");
format(string,sizeof(string),"AdmWarn: %s has slapped %s, they were slapped %d meters high.", RPN(playerid), RPN(playerid), height);
SendAdminMessage(COLOR_LIGHTRED, 1, string);
return 1;
}