Simple Slap command
#1

Hey this is probably an easy question for alot of you, and yea I could just go look in other scripts..
but I'm slowly learning to script and I'd appriciate it alot if you could show and explain or just show and I'll figure it out myself how to make this.

I got a slap commands that only shows some text and takes some HP off the player, but I want him to fly upwards aswell, what do I need to do?

dcmd_slap(playerid,params[]) {
if(IsPlayerCommandLevel(playerid,"slap")) {
if(!strlen(params)) return SendClientMessage(playerid,red,"Wrong Fromat: /SLAP <NICK OR ID>");
new id; if(!IsNumeric(params)) id = ReturnPlayerID(params); else id = strval(params);
if(IsPlayerConnected(id) && id != INVALID_PLAYER_ID && id != playerid) {
SendCommandMessageToAdmins(playerid,"SLAP");
new string[256],name[24],ActionName[24]; GetPlayerName(playerid,name,24); GetPlayerName(id,ActionName,24);
format(string,256,"Administrator \"%s\" has bitch-slapped \"%s\".",name,ActionName); SendClientMessageToAll(yellow,string);
new Float:Health; GetPlayerHealth(id,Health); return SetPlayerHealth(id,Health-Config[SlapDecrement]);
} else return SendClientMessage(playerid,red,"ERROR: You can not slap yourself or a disconnected player.");
} else return SendLevelErrorMessage(playerid,"slap");
Reply
#2

pawn Код:
new Float:X, Float:Y, Float:Z;
GetPlayerPos(id, X, Y, Z);
SetPlayerPos(id, X, Y, Z+5);
//The Z axis is up/down in a 3D world. So when you set it higher, they're higher off the ground.
Reply
#3

Quote:
Originally Posted by [ABK]Antonio
Посмотреть сообщение
pawn Код:
new Float:X, Float:Y, Float:Z;
GetPlayerPos(id, X, Y, Z);
SetPlayerPos(id, X, Y, Z+5);
//The Z axis is up/down in a 3D world. So when you set it higher, they're higher off the ground.
Thanks
Reply
#4

dcmd_slap(playerid,params[]) {
if(IsPlayerCommandLevel(playerid,"slap")) {
if(!strlen(params)) return SendClientMessage(playerid,red,"Wrong Fromat: /SLAP <NICK OR ID>");
new id; if(!IsNumeric(params)) id = ReturnPlayerID(params); else id = strval(params);
if(IsPlayerConnected(id) && id != INVALID_PLAYER_ID && id != playerid) {
SendCommandMessageToAdmins(playerid,"SLAP");
new string[256],name[24],ActionName[24]; GetPlayerName(playerid,name,24); GetPlayerName(id,ActionName,24);
format(string,256,"Administrator \"%s\" has bitch-slapped \"%s\".",name,ActionName); SendClientMessageToAll(yellow,string);
new Float:Health; GetPlayerHealth(id,Health); return SetPlayerHealth(id,Health-Config[SlapDecrement]);
new Float:X, Float:Y, Float:Z;
GetPlayerPos(id, X, Y, Z);
SetPlayerPos(id, X, Y, Z+5);
} else return SendClientMessage(playerid,red,"ERROR: You can not slap yourself or a disconnected player.");
} else return SendLevelErrorMessage(playerid,"slap");

Like this or am I totally wrong?

I get a few warnings

: warning 217: loose indentation
: warning 225: : warning 217: loose indentation
: warning 209: function "dcmd_slap" should return a value
Reply
#5

Edited this : GetPlayerPos(playerid, X, Y, Z);
SetPlayerPos(playerid, X, Y, Z+5); return 0;

But still getting warnings
Reply
#6

pawn Код:
dcmd_slap(playerid,params[]) {
    if(!IsPlayerCommandLevel(playerid,"slap")) return SendLevelErrorMessage(playerid,"slap");
    if(!strlen(params)) return SendClientMessage(playerid,red,"Wrong Fromat: /SLAP <NICK OR ID>");
    new id; if(!IsNumeric(params)) id = ReturnPlayerID(params); else id = strval(params);
    if(!IsPlayerConnected(id) || id == playerid) return SendClientMessage(playerid,red,"ERROR: You can not slap yourself or a disconnected player.");

    new Float:Health, Float:X, Float:Y, Float:Z;
    GetPlayerHealth(id,Health); SetPlayerHealth(id,Health-Config[SlapDecrement]);
    GetPlayerPos(id, X, Y, Z); SetPlayerPos(id, X, Y, Z+5);

    new string[128],name[MAX_PLAYER_NAME],ActionName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name)); GetPlayerName(id,ActionName,sizeof(ActionName));
    format(string,sizeof(string),"Administrator \"%s\" has bitch-slapped \"%s\".",name,ActionName);
    SendClientMessageToAll(yellow,string);

    return SendCommandMessageToAdmins(playerid,"SLAP");
}
Try that out

Also, you should use the [ pawn] tags (without the space) so it indents properly :P
Reply
#7

Quote:
Originally Posted by [ABK]Antonio
Посмотреть сообщение
pawn Код:
dcmd_slap(playerid,params[]) {
    if(!IsPlayerCommandLevel(playerid,"slap")) return SendLevelErrorMessage(playerid,"slap");
    if(!strlen(params)) return SendClientMessage(playerid,red,"Wrong Fromat: /SLAP <NICK OR ID>");
    new id; if(!IsNumeric(params)) id = ReturnPlayerID(params); else id = strval(params);
    if(!IsPlayerConnected(id) || id == playerid) return SendClientMessage(playerid,red,"ERROR: You can not slap yourself or a disconnected player.");

    new Float:Health, Float:X, Float:Y, Float:Z;
    GetPlayerHealth(id,Health); SetPlayerHealth(id,Health-Config[SlapDecrement]);
    GetPlayerPos(id, X, Y, Z); SetPlayerPos(id, X, Y, Z+5);

    new string[128],name[MAX_PLAYER_NAME],ActionName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name)); GetPlayerName(id,ActionName,sizeof(ActionName));
    format(string,sizeof(string),"Administrator \"%s\" has bitch-slapped \"%s\".",name,ActionName);
    SendClientMessageToAll(yellow,string);

    return SendCommandMessageToAdmins(playerid,"SLAP");
}
Try that out

Also, you should use the [ pawn] tags (without the space) so it indents properly :P
Thanks! I will
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)