Commands problem.
#1

Hi all.
I have a problem with two commands.
One is /sethp, the other /engine.

Engine:

When I digit /engine, nothing happens.
pawn Код:
CMD:engine(playerid, params[])
{
    new string[256];
    new engine, lights, alarm, doors, bonnet, boot, objective;
    new veicolo = GetPlayerVehicleID(playerid);
    GetVehicleParamsEx(veicolo, engine, lights, alarm, doors, bonnet, boot, objective);
    if(!IsPlayerInAnyVehicle(playerid)) return 1;
    if(engine == VEHICLE_PARAMS_OFF) {
    format(string, sizeof(string), "* > %s gira la chiave ed accende il motore del veicolo.");
    SetPlayerChatBubble(playerid, string, COLOR_PURPLE, 25.0, 1500);
    SendClientMessage(playerid, COLOR_PURPLE, string);
    SetVehicleParamsEx(veicolo, 1, 1, 0, 0, 0, 0, 0);
    } else if(engine == VEHICLE_PARAMS_ON) {
    format(string, sizeof(string), "* > %s gira la chiave e spenge il motore del veicolo.");
    SetPlayerChatBubble(playerid, string, COLOR_PURPLE, 25.0, 1500);
    SendClientMessage(playerid, COLOR_PURPLE, string);
    SetVehicleParamsEx(veicolo, 0, 0, 0, 0, 0, 0, 0); }
    return 1;
}
Sethp:

When I digit /sethp [name] [amount], sometimes sets the HP to 48.

pawn Код:
CMD:sethp(playerid, params[])
{
if(PlayerData[playerid][AdminLevel] < 1) return SendUnathorizedMessage(playerid);
new target, vita, string[256], string1[256];
if(sscanf(params, "us[129]", target, vita)) return SendClientMessage(playerid, COLOR_SEABLUE, "{999999}Uso:{FFFFFF} /sethp [ID/Parte del nome] [quantitа]");
   if(IsPlayerConnected(target)) {
       if(!gIsPlayerLoggedIn[target]) return SendPlayerNotLoggedInMessage(playerid);
       SetPlayerHealth(target, vita);
       format(string, sizeof(string), "{999999}SERVER:{FFFFFF} Un admin ti ha settato gli HP a %d", vita);
       SendClientMessage(target, COLOR_WHITE, string);
       format(string1, sizeof(string1), "Admin:{FFFFFF} %s ha settato a %s gli HP a %d", GetPlayersName(playerid), GetPlayersName(target), vita);
       SendAdministratorMessage(string1); }
       return 1;
}
Thank you in advance.
Reply
#2

in /sethp, you should use floats, not string to set health.
Reply
#3

What if it is unset (-1)? You don't check that:
pawn Код:
if(engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET)
and health is float so you should declare a variable with Float: tag and use "f" specifier at sscanf.

pawn Код:
CMD:sethp(playerid, params[])
{
    if(PlayerData[playerid][AdminLevel] < 1) return SendUnathorizedMessage(playerid);
    new target, Float: vita;
    if(sscanf(params, "uf", target, vita)) return SendClientMessage(playerid, COLOR_SEABLUE, "{999999}Uso:{FFFFFF} /sethp [ID/Parte del nome] [quantitа]");
    if(IsPlayerConnected(target))
    {
        if(!gIsPlayerLoggedIn[target]) return SendPlayerNotLoggedInMessage(playerid);
        SetPlayerHealth(target, vita);
        new string[128];
        format(string, sizeof(string), "{999999}SERVER:{FFFFFF} Un admin ti ha settato gli HP a %.0f", vita);
        SendClientMessage(target, COLOR_WHITE, string);
        format(string, sizeof(string), "Admin:{FFFFFF} %s ha settato a %s gli HP a %.0f", GetPlayersName(playerid), GetPlayersName(target), vita);
        SendAdministratorMessage(string);
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by Richie©
Посмотреть сообщение
in /sethp, you should use floats, not string to set health.
Same thing with Float:vita.
Reply
#5

For the engine command, are you using ManualVehicleEngineAndLights?
Reply
#6

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
What if it is unset (-1)? You don't check that:
pawn Код:
if(engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET)
and health is float so you should declare a variable with Float: tag and use "f" specifier at sscanf.

pawn Код:
CMD:sethp(playerid, params[])
{
    if(PlayerData[playerid][AdminLevel] < 1) return SendUnathorizedMessage(playerid);
    new target, Float: vita;
    if(sscanf(params, "uf", target, vita)) return SendClientMessage(playerid, COLOR_SEABLUE, "{999999}Uso:{FFFFFF} /sethp [ID/Parte del nome] [quantitа]");
    if(IsPlayerConnected(target))
    {
        if(!gIsPlayerLoggedIn[target]) return SendPlayerNotLoggedInMessage(playerid);
        SetPlayerHealth(target, vita);
        new string[128];
        format(string, sizeof(string), "{999999}SERVER:{FFFFFF} Un admin ti ha settato gli HP a %.0f", vita);
        SendClientMessage(target, COLOR_WHITE, string);
        format(string, sizeof(string), "Admin:{FFFFFF} %s ha settato a %s gli HP a %.0f", GetPlayersName(playerid), GetPlayersName(target), vita);
        SendAdministratorMessage(string);
    }
    return 1;
}
Thank you! REP+!
Reply


Forum Jump:


Users browsing this thread: