SA-MP Forums Archive
Help with /carhealth - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help with /carhealth (/showthread.php?tid=533357)



Help with /carhealth - Snail - 24.08.2014

Hi all.

I have made a /carhealth command but I'm getting one error.

Here is the code:
pawn Код:
CMD:carhealth(playerid,params)
{
    new pid, ch = GetPlayerVehicleID(playerid), str[128], pidn[MAX_PLAYER_NAME], amount;
    if(!IsPlayerAdmin(playerid)) return SCM(playerid,COLOR_RED,"ERROR: You must be an RCON to use this command!");
    if(sscanf(params,"ui", pid, amount)) return SCM(playerid,COLOR_RED,"USAGE: /carhealth <id> <amount>");
    if(!IsPlayerConnected(pid)) return SCM(playerid,COLOR_RED,"ERROR: That player is not connected!");
    GPN(pid, pidn, MAX_PLAYER_NAME);
    FT(str, sizeof(str), "[CAR]:You have set %s's Car Health to %i!", pidn, amount);
    SCM(playerid, NICE_PINK, str);
    SetVehicleHealth(ch, amount);
    return 1;
}
The error is this:
pawn Код:
C:\Users\George\Desktop\SAMP Server\filterscripts\cmds.pwn(788) : error 035: argument type mismatch (argument 1)
Thanks


Re: Help with /carhealth - SickAttack - 24.08.2014

"amount" must be a float.

pawn Код:
CMD:carhealth(playerid,params)
{
    new pid, ch = GetPlayerVehicleID(playerid), str[128], pidn[MAX_PLAYER_NAME], Float:amount;
    if(!IsPlayerAdmin(playerid)) return SCM(playerid,COLOR_RED,"ERROR: You must be an RCON to use this command!");
    if(sscanf(params,"uf", pid, amount)) return SCM(playerid,COLOR_RED,"USAGE: /carhealth <id> <amount>");
    if(!IsPlayerConnected(pid)) return SCM(playerid,COLOR_RED,"ERROR: That player is not connected!");
    GPN(pid, pidn, MAX_PLAYER_NAME);
    FT(str, sizeof(str), "[CAR]:You have set %s's Car Health to %f!", pidn, amount);
    SCM(playerid, NICE_PINK, str);
    SetVehicleHealth(ch, amount);
    return 1;
}



Re: Help with /carhealth - 1fret - 24.08.2014

-DELETED -


Re: Help with /carhealth - Snail - 24.08.2014

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
"amount" must be a float.

pawn Код:
CMD:carhealth(playerid,params)
{
    new pid, ch = GetPlayerVehicleID(playerid), str[128], pidn[MAX_PLAYER_NAME], Float:amount;
    if(!IsPlayerAdmin(playerid)) return SCM(playerid,COLOR_RED,"ERROR: You must be an RCON to use this command!");
    if(sscanf(params,"uf", pid, amount)) return SCM(playerid,COLOR_RED,"USAGE: /carhealth <id> <amount>");
    if(!IsPlayerConnected(pid)) return SCM(playerid,COLOR_RED,"ERROR: That player is not connected!");
    GPN(pid, pidn, MAX_PLAYER_NAME);
    FT(str, sizeof(str), "[CAR]:You have set %s's Car Health to %f!", pidn, amount);
    SCM(playerid, NICE_PINK, str);
    SetVehicleHealth(ch, amount);
    return 1;
}
Still getting the same error


Re: Help with /carhealth - 1fret - 24.08.2014

Show line 788 that where the error is at


Re: Help with /carhealth - SickAttack - 24.08.2014

pawn Код:
CMD:carhealth(playerid, params[])
{
    new string[128], id, Float:amount, name[MAX_PLAYER_NAME];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "ERROR: You must be an RCON to use this command!");
    if(sscanf(params, "uf", id, amount)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /carhealth <id> <amount>");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: That player is not connected!");
    GetPlayerName(id, name, sizeof(name));
    format(string, sizeof(string), "[CAR]:You have set %s's Car Health to %f!", name, amount);
    SendClientMessage(playerid, COLOR_RED, string);
    SetVehicleHealth(GetPlayerVehicleID(playerid), amount);
    return 1;
}
pawn Код:
CMD:carhealth(playerid, params[])
"params" is a string and strings must contain "[]" as a perfix.


Re: Help with /carhealth - Snail - 24.08.2014

Quote:
Originally Posted by 1fret
Посмотреть сообщение
Show line 788 that where the error is at
It's 789 now.
Here is the line
pawn Код:
if(sscanf(params,"uf", pid, amount)) return SCM(playerid,COLOR_RED,"USAGE: /carhealth <id> <amount>");



Re: Help with /carhealth - Snail - 24.08.2014

nvm, i got it working now.

thanks


Re: Help with /carhealth - SickAttack - 24.08.2014

Post was updated.. I made it with my command processor, and it has different parameters. It should work now..


Re: Help with /carhealth - Snail - 24.08.2014

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Post was updated.. I made it with my command processor, and it has different parameters. It should work now..
I have a problem

when I do /carhealth 0 100 it shows
[CAR]:You have set Snail's Car Health to 100.000000!

And the car is on fire..