/slap command help
#1

I have a code for '/slap [id] [height]' but it will not slap the player into the air at all... I am not good at trying to explain this but if you could look at the code and help me fix this.

Код:
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;
}
Reply
#2

You're missing a sscanf specifier.

pawn Код:
if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /slap [playerid] [height]");
So, your height var will always equal 0.
Reply
#3

What do you mean?

FIXED
Reply
#4

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
You're missing a sscanf specifier.

pawn Код:
if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /slap [playerid] [height]");
So, your height var will always equal 0.
Is

pawn Код:
if(sscanf(params, "ui", playerb,height)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /slap [playerid] [height]");
Reply
#5

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

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
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);
if height is not set sscanf will return the sendClientMessage
Reply
#7

Or, make the height an OPTIONAL specifier and default the value to whatever you want.
Reply
#8

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Or, make the height an OPTIONAL specifier and default the value to whatever you want.
This only with sscanf plugin, i say right?
Reply
#9

Quote:
Originally Posted by iJumbo
Посмотреть сообщение
if height is not set sscanf will return the sendClientMessage
Just re-write it then you make it sound like you need to use sscanf in a if statement.

Код:
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;
}
Was that hard? Took 30 seconds to modify.
Reply
#10

More problems, I am trying to make it so i can not slap over 100 meters but yet it slaps me then gives me the message about it.

code
Код:
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;
}
Help me once more plz haha
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)