Need Help with /slap
#1

i'm making my own slap command but suddenly i have mistake in this part

pawn Код:
SetPlayerHealth(id,GetPlayerHealth(id) - 10.0);
i got those warnings:

Код:
H:\GTA San Andreas\SAMP Server\filterscripts\Admin.pwn(945) : warning 202: number of arguments does not match definition
H:\GTA San Andreas\SAMP Server\filterscripts\Admin.pwn(945) : warning 213: tag mismatch
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.
CODE:

pawn Код:
CMD:slap(playerid,params[])
{
    new id,
        reason[128],
        adminname[MAX_PLAYER_NAME],
        pname[MAX_PLAYER_NAME];
    GetPlayerName(id,pname,MAX_PLAYER_NAME);
    GetPlayerName(playerid,adminname,MAX_PLAYER_NAME);
    if(sscanf(params,"uz",id, reason)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /slap <playername/id> <reason>");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"ERROR: Player is not connected!");
    SetPlayerScore(id, GetPlayerHealth(id) - 10.0);
    PlayerPlaySound(1149,0,0,0,0);
    return 1;
}
Pls help ASAP
Reply
#2

pawn Код:
CMD:slap(playerid,params[])
{
    new id,
        reason[128],
        adminname[MAX_PLAYER_NAME],
        pname[MAX_PLAYER_NAME],
       Float:health;
    GetPlayerName(id,pname,MAX_PLAYER_NAME);
    GetPlayerName(playerid,adminname,MAX_PLAYER_NAME);
    if(sscanf(params,"us[128]",id, reason)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /slap <playername/id> <reason>");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"ERROR: Player is not connected!");
    GetPlayerHealth(id, health);
    SetPlayerHealth(id, health - 10.0);
    PlayerPlaySound(1149,0,0,0,0);
    return 1;
}
Reply
#3

GetPlayerHealth doesn't work like that.
You have to store the health in a float, like this:
pawn Код:
new Float:hp;
GetPlayerHealth(id, hp);
Quote:
Originally Posted by Cypress
Посмотреть сообщение
pawn Код:
SetPlayerScore(id, -1); // - the amount you want
Wow, that's just.. wow..
You're setting that player's score to -1. You aren't decreasing it. If you want to decrease it you need to use this:
pawn Код:
SetPlayerScore(id, GetPlayerScore(id)-10);
Reply
#4

pawn Код:
SetPlayerHealth(id, -10.0);
This set's the playerid's health to -10, but he wants to reduce the health by 10.
Try this:

pawn Код:
CMD:slap(playerid,params[])
{
    new id;
    new Float:health;
    new reason[128];
    new adminname[MAX_PLAYER_NAME], pname[MAX_PLAYER_NAME];
    GetPlayerName(id,pname,MAX_PLAYER_NAME);
    GetPlayerName(playerid,adminname,MAX_PLAYER_NAME);
    if(sscanf(params,"us[128]",id, reason)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /slap <playername/id> <reason>");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"ERROR: Player is not connected!");
    GetPlayerHealth(id, health);
    SetPlayerHealth(id, health -10.0);
    PlayerPlaySound(1149,0,0,0,0);
    return 1;
}
Reply
#5

i only want is example my health is 100 when it gets slap it will be 90
Reply
#6

Quote:
Originally Posted by Drebin
Посмотреть сообщение
pawn Код:
SetPlayerHealth(id, -10.0);
This set's the playerid's health to -10, but he wants to reduce the health by 10:

pawn Код:
CMD:slap(playerid,params[])
{
    new id,
    new Float:health;
    reason[128],
    adminname[MAX_PLAYER_NAME],
    pname[MAX_PLAYER_NAME];
    GetPlayerName(id,pname,MAX_PLAYER_NAME);
    GetPlayerName(playerid,adminname,MAX_PLAYER_NAME);
    if(sscanf(params,"uz",id, reason)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /slap <playername/id> <reason>");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"ERROR: Player is not connected!");
    GetPlayerHealth(id, health);
    SetPlayerHealth(id, health -10.0);
    PlayerPlaySound(1149,0,0,0,0);
    return 1;
}
pawn Код:
new id,
    new Float:health;
    reason[128],
    adminname[MAX_PLAYER_NAME],
    pname[MAX_PLAYER_NAME];
There is already a new parameter.

Quote:
Originally Posted by GAMER_PS2
Посмотреть сообщение
i only want is example my health is 100 when it gets slap it will be 90
Check the command I posted above.
Reply
#7

one problem

Код:
[14:53:52] sscanf warning: 'z' is deprecated, consider using 'S' instead.
[14:53:52] sscanf warning: No default value found.
[14:53:52] sscanf warning: Strings without a length are deprecated, please add a destination size.
Reply
#8

Quote:
Originally Posted by Cypress
Посмотреть сообщение
pawn Код:
new id,
    new Float:health;
    reason[128],
    adminname[MAX_PLAYER_NAME],
    pname[MAX_PLAYER_NAME];
There is already a new parameter.
Mate, in that code above is no parameter at all. I don't even see a callback, stock, native, whatever. Or am I blind?

@GAMER_PS2
Use the code of Drebin, that one is fine. However if you want to slap someone to CHECK if he's hacking, then you shouldn't lower his HP by 10, but you should slap him high enough for him to lose HP. If he doesn't lose HP, he's hacking.
Reply
#9

fixd' my code.
Reply
#10

Quote:
Originally Posted by GAMER_PS2
Посмотреть сообщение
one problem

Код:
[14:53:52] sscanf warning: 'z' is deprecated, consider using 'S' instead.
[14:53:52] sscanf warning: No default value found.
[14:53:52] sscanf warning: Strings without a length are deprecated, please add a destination size.
pawn Код:
if(sscanf(params,"us[128]",id, reason)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /slap <playername/id> <reason>");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)