dcmd_sethp and dcmd_armour are only setting own hp and armour
#1

Well, the subject says it all.. I'm ID 11, I want ID 7's armour (/setarmour 7 100) but it sets mine...

pawn Код:
dcmd_sethp(playerid,params[])
{
    new Float:Health,target;
    if(pInfo[playerid][pAdmin] < 3) return SystemMessage(playerid, "You are not an Administrator with the required level.");
    if(sscanf(params,"uf",target,Health)) return SystemMessage(playerid, "USAGE: /sethp [playername/id] [health]");

    SetPlayerHealth2(playerid,Health);
    return 1;
}

dcmd_setarmour(playerid,params[])
{
    new Float:Armour,target;
    if(pInfo[playerid][pAdmin] < 3) return SystemMessage(playerid, "You are not an Administrator with the required level.");
    if(sscanf(params,"uf",target,Armour)) return SystemMessage(playerid, "USAGE: /setarmour [playername/id] [armour]");

    SetPlayerArmour(playerid,Armour);
    return 1;
}
Last line of my script.
pawn Код:
stock SetPlayerHealth2(playerid, Float:health)
{
  new intbroj = floatround(health);
    SetPlayerHealth(playerid, intbroj);
    return 1;
}
Reply
#2

playerid means to set the health of the person who uses the command , try this (not tested)

Код:
dcmd_sethp(playerid,params[])
{
new tmp[128];
new target = strval(tmp)
new Float:Health;
GetPlayerHealth(target,Health);
if(pInfo[playerid][pAdmin] < 3) return SystemMessage(playerid, "You are not an Administrator with the required level.");
if(sscanf(params,"uf",target,Health)) return SystemMessage(playerid, "USAGE: /setarmour [playername/id] [armour]");
else {
SetPlayerHealth(target,Health);
}
return 1;
}
same for armour :

Код:
dcmd_setarmour(playerid,params[])
{
new tmp[128];
new target = strval(tmp)
new Float:Armour;
GetPlayerArmour(target,Armour);
if(pInfo[playerid][pAdmin] < 3) return SystemMessage(playerid, "You are not an Administrator with the required level.");
if(sscanf(params,"uf",target,Armour)) return SystemMessage(playerid, "USAGE: /sethp [playername/id] [health]");
else {
SetPlayerArmour(target,Armour);
}
return 1;
}
Reply
#3

as per previous comment (good answer)

playerid is always you so you need to tell it that its not player id. in the instance of the previous answer target has been assigned the parameter that you enter (the playerid of the person you are doing it for).
Reply
#4

pawn Код:
dcmd_sethp(playerid,params[])
{
    new Float:Health,target;
    if(pInfo[playerid][pAdmin] < 3) return SystemMessage(playerid, "You are not an Administrator with the required level.");
    if(sscanf(params,"uf",target,Health)) return SystemMessage(playerid, "USAGE: /sethp [playername/id] [health]");
    SetPlayerHealth2(target,Health);
    return 1;
}
dcmd_setarmour(playerid,params[])
{
    new Float:Armour,target;
    if(pInfo[playerid][pAdmin] < 3) return SystemMessage(playerid, "You are not an Administrator with the required level.");
    if(sscanf(params,"uf",target,Armour)) return SystemMessage(playerid, "USAGE: /setarmour [playername/id] [armour]");
    SetPlayerArmour(target,Armour);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)