SA-MP Forums Archive
Commands needs to be typed 2 times before working and showing wrong - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Commands needs to be typed 2 times before working and showing wrong (/showthread.php?tid=132203)



Commands needs to be typed 2 times before working and showing wrong - Andy_McKinley - 06.03.2010

I've got a problem with my admin cmd ''/whois''
It shows player stats; Name, ID, money, IP, armour, health. But it ain't working correctly; Showing wrong stats.

Like this:

| Name: [UF]DarkPhoenix | ID: 11 | Money: $205386 | IP: 111.111.111.111 | Health: 100.00000000 | Armour: 0.000000000

And when I want to check stats of someone else it shows HIS/HER name, ID, money by MY IP, Health and Armour... After I typed it again it works fine. This always happens. I don't want Health and Armour ''100.0000000000'' or ''95.000000000'' I just want it like ''100'' or ''75'', etc.

This is my script:

pawn Код:
dcmd_whois(playerid, params[])
{
  new index = 0;
    new playermoney;
   
    new PlayerIP[16];
    GetPlayerIp(giveplayerid,PlayerIP,sizeof(PlayerIP));
   
    new Float:pHealth,Float:pArmour;
    GetPlayerHealth(playerid,pHealth);
    GetPlayerArmour(playerid,pArmour);

  tmp2 = strtok(params, index);
    if (pInfo[playerid][pAdmin] < 1)
    {
        SystemMessage(playerid, "You are not an Administrator with the required level.");
        return 1;
    }
  if(!strlen(tmp2))
    {
        SystemMessage(playerid, "[USAGE] ''/whois [playername/id]''.");
        return 1;
    }
   
    new string[MAX_STRING];
    giveplayerid = ReturnUser(tmp2);
    if (IsPlayerConnected(giveplayerid))
    {
        playermoney = GetPlayerMoney(giveplayerid);
        format(string, sizeof(string), "| Name: %s | ID: %d | Money: $%d | IP: %s | Health: %f | Armour: %f", PlayerName(giveplayerid), giveplayerid, playermoney, PlayerIP, pHealth, pArmour);
        SystemMessage(playerid, string);
    }
    else
  {
        format(string, sizeof(string), "That player is not active.");
        SystemMessage(playerid, string);
    }
    return 1;
}
Anyone knows what is wrong?


Re: Commands needs to be typed 2 times before working and showing wrong - ¤Adas¤ - 06.03.2010

pawn Код:
dcmd_whois(playerid, params[])
{
  new index;
    new playermoney;

if(!strlen(params))
    {
        SystemMessage(playerid, "[USAGE] ''/whois [playername/id]''.");
        return 1;
    }

giveplayerid = ReturnUser(params);
   
    new PlayerIP[16];
    GetPlayerIp(giveplayerid,PlayerIP,sizeof(PlayerIP));
   
    new Float:pHealth,Float:pArmour;
    GetPlayerHealth(giveplayerid,pHealth);
    GetPlayerArmour(giveplayerid,pArmour);

    if (pInfo[playerid][pAdmin] < 1)
    {
        SystemMessage(playerid, "You are not an Administrator with the required level.");
        return 1;
    }
   
    new string[MAX_STRING];
    if (IsPlayerConnected(giveplayerid))
    {
        playermoney = GetPlayerMoney(giveplayerid);
        format(string, sizeof(string), "| Name: %s | ID: %d | Money: $%d | IP: %s | Health: %.1f | Armour: %.1f", PlayerName(giveplayerid), giveplayerid, playermoney, PlayerIP, pHealth, pArmour);
        SystemMessage(playerid, string);
    }
    else
  {
        format(string, sizeof(string), "That player is not active.");
        SystemMessage(playerid, string);
    }
    return 1;
}



Re: Commands needs to be typed 2 times before working and showing wrong - Andy_McKinley - 06.03.2010

Thank you! That one works fine. But now I wanted to add player weapons, but I have no experience with GetWeaponData.

Could someone help me with this command (adding weapons - showing player weapons)

pawn Код:
dcmd_whois(playerid, params[])
{
    new playermoney;

if(!strlen(params))
    {
        SystemMessage(playerid, "[USAGE] ''/whois [playername/id]''.");
        return 1;
    }

giveplayerid = ReturnUser(params);

    new Float:pWeapons
    GetPlayerWeapons(giveplayerid, pWeapons);

    new Float:pHealth,Float:pArmour;
    GetPlayerHealth(giveplayerid,pHealth);
    GetPlayerArmour(giveplayerid,pArmour);
   
    new PlayerIP[16];
    GetPlayerIp(giveplayerid,PlayerIP,sizeof(PlayerIP));

    if (pInfo[playerid][pAdmin] < 1)
    {
        SystemMessage(playerid, "You are not an Administrator with the required level.");
        return 1;
    }

    new string[MAX_STRING];
    if (IsPlayerConnected(giveplayerid))
    {
        playermoney = GetPlayerMoney(giveplayerid);
        format(string, sizeof(string), "Name: %s | ID: %d | Money: $%d | Weapon(s): | Health: %.1f | Armour: %.1f | IP: %s ", PlayerName(giveplayerid), giveplayerid, playermoney,, pWeapons, pHealth, pArmour, PlayerIP);
        SystemMessage(playerid, string);
    }
    else
  {
        format(string, sizeof(string), "That player is not active.");
        SystemMessage(playerid, string);
    }
    return 1;
}
this command ain't working


Re: Commands needs to be typed 2 times before working and showing wrong - ¤Adas¤ - 06.03.2010

GetPlayerWeaponData


Re: Commands needs to be typed 2 times before working and showing wrong - Andy_McKinley - 06.03.2010

Quote:
Originally Posted by ¤Adas¤
I forgot to say this; I already searched but I don't understand wiki...


Re: Commands needs to be typed 2 times before working and showing wrong - ¤Adas¤ - 06.03.2010

I think, it is useless to write all player's weapon data in this command. Let there be GetPlayerWeapon for the beginning.


Re: Commands needs to be typed 2 times before working and showing wrong - Andy_McKinley - 07.03.2010

Quote:
Originally Posted by ¤Adas¤
I think, it is useless to write all player's weapon data in this command. Let there be GetPlayerWeapon for the beginning.
That's the problem, there's always showing an error that's why I made this thread.


Re: Commands needs to be typed 2 times before working and showing wrong - Andy_McKinley - 07.03.2010

bump


Re: Commands needs to be typed 2 times before working and showing wrong - ¤Adas¤ - 07.03.2010

Quote:
Originally Posted by DarkPhoenix
Quote:
Originally Posted by ¤Adas¤
I think, it is useless to write all player's weapon data in this command. Let there be GetPlayerWeapon for the beginning.
That's the problem, there's always showing an error that's why I made this thread.
Show us the errors and error lines again.


Re: Commands needs to be typed 2 times before working and showing wrong - Andy_McKinley - 07.03.2010

Quote:
Originally Posted by ¤Adas¤
Quote:
Originally Posted by DarkPhoenix
Quote:
Originally Posted by ¤Adas¤
I think, it is useless to write all player's weapon data in this command. Let there be GetPlayerWeapon for the beginning.
That's the problem, there's always showing an error that's why I made this thread.
Show us the errors and error lines again.
This is the script
pawn Код:
dcmd_whois(playerid, params[])
{
    new playermoney;

if(!strlen(params))
    {
        SystemMessage(playerid, "[USAGE] ''/whois [playername/id]''.");
        return 1;
    }

giveplayerid = ReturnUser(params);

    new Float:pWeapons
    GetPlayerWeapons(giveplayerid, pWeapons);

    new Float:pHealth,Float:pArmour;
    GetPlayerHealth(giveplayerid,pHealth);
    GetPlayerArmour(giveplayerid,pArmour);
   
    new PlayerIP[16];
    GetPlayerIp(giveplayerid,PlayerIP,sizeof(PlayerIP));

    if (pInfo[playerid][pAdmin] < 1)
    {
        SystemMessage(playerid, "You are not an Administrator with the required level.");
        return 1;
    }

    new string[MAX_STRING];
    if (IsPlayerConnected(giveplayerid))
    {
        playermoney = GetPlayerMoney(giveplayerid);
        format(string, sizeof(string), "Name: %s | ID: %d | Money: $%d | Weapon(s): | Health: %.1f | Armour: %.1f | IP: %s ", PlayerName(giveplayerid), giveplayerid, playermoney,, pWeapons, pHealth, pArmour, PlayerIP);
        SystemMessage(playerid, string);
    }
    else
  {
        format(string, sizeof(string), "That player is not active.");
        SystemMessage(playerid, string);
    }
    return 1;
}
No weapon showing...