Check Player Weapon Info
#1

Hey I have been trying to make a command for the police officers on my server were it tells you what weapon they have.

Please Post If you have a command so i have something to go from

Thanks
Reply
#2

Quote:
Originally Posted by Red Hockey
Hey I have been trying to make a command for the police officers on my server were it tells you what weapon they have.

Please Post If you have a command so i have something to go from

Thanks
https://sampwiki.blast.hk/wiki/GetPlayerWeaponData

Hope this helps.
Reply
#3

Quote:
Originally Posted by mprofitt
Quote:
Originally Posted by Red Hockey
Hey I have been trying to make a command for the police officers on my server were it tells you what weapon they have.

Please Post If you have a command so i have something to go from

Thanks
https://sampwiki.blast.hk/wiki/GivePlayerWeapon

Hope this helps.
Wrong link.

https://sampwiki.blast.hk/wiki/GetPlayerWeaponData
Reply
#4

I know i have tried using this and making my own but have failed. I need something to go from
Reply
#5

Quote:
Originally Posted by Red Hockey
I know i have tried using this and making my own but have failed. I need something to go from
Something like, the cops do /check on a player id, then they get a message saying the player has weapons on him?
Reply
#6

yes
Reply
#7

Any ideas
Reply
#8

Here, I've adapted something from my script to work for your /check command:

pawn Код:
new wNamesShortened[][32] = {
    {"Unarmed (Fist)"}, // 0
    {"Brass Knuckles"}, // 1
    {"Golf Club"}, // 2
    {"Night Stick"}, // 3
    {"Kn."}, // 4
    {"Baseball Bat"}, // 5
    {"Shovel"}, // 6
    {"Pool Cue"}, // 7
    {"Katana"}, // 8
    {"Chainsaw"}, // 9
    {"Purple Dildo"}, // 10
    {"Big White Vibrator"}, // 11
    {"Medium White Vibrator"}, // 12
    {"Small White Vibrator"}, // 13
    {"Flowers"}, // 14
    {"Cane"}, // 15
    {"Grenade"}, // 16
    {"Teargas"}, // 17
    {"Molotov"}, // 18
    {" "}, // 19
    {" "}, // 20
    {" "}, // 21
    {"Colt 45"}, // 22
    {"Silenced"}, // 23
    {"Deagle"}, // 24
    {"Shotgun"}, // 25
    {"Sawnoff"}, // 26
    {"Combat"}, // 27
    {"Uzi"}, // 28
    {"MP5"}, // 29
    {"AK47"}, // 30
    {"M4"}, // 31
    {"Tec9"}, // 32
    {"Rifle"}, // 33
    {"Sniper"}, // 34
    {"RPG"}, // 35
    {"HS RPG"}, // 36
    {"Flamethrower"}, // 37
    {"Minigun"}, // 38
    {"Satchel Charge"}, // 39
    {"Detonator"}, // 40
    {"Spray Can"}, // 41
    {"Fire Extinguisher"}, // 42
    {"Camera"}, // 43
    {"NVG"}, // 44
    {"IVG"}, // 45
    {"Para."}, // 46
    {"Fake Pistol"} // 47
};

stock ReturnPlayerWeaponsString(playerid)
{
    new string[128];
    new WeaponID, Ammo;
    for(new i = 0; i < 13; i++)
    {
      if(i == 0 || i == 1)
        {
            GetPlayerWeaponData(playerid,i,WeaponID,Ammo);
            if(Ammo > 1)
            {
              Ammo = 1;
            }
      }
        else
        {
            GetPlayerWeaponData(playerid,i,WeaponID,Ammo);
        }
        if(WeaponID > 0 && Ammo > 0)
        {
          if(Ammo > 60000) //melee weaps
            Ammo = 1;

          if(strlen(string) > 4)
                format(string,128,"%s %s(%d),", string, wNamesShortened[WeaponID], Ammo);
            else
                format(string,128,"%s(%d),", wNamesShortened[WeaponID], Ammo);//First Weapon
        }
    }
    if(strlen(string) < 3)
    {
        string = "N/A";
    }
    return string;
}

zcmd(check, playerid, params[])
{
    new checkid;
    if (!sscanf(params, "u", checkid))
    {
        if(!IsPlayerConnected(checkid)) return SendClientMessage(playerid, 0xAFAFAFAA, "* That player is not connected.");
        if(checkid == playerid) return SendClientMessage(playerid, 0xAFAFAFAA, "* You cannot check yourself yourself");
        new SM_PNstring [128], playername[MAX_PLAYER_NAME];
        GetPlayerName(checkid,playername,sizeof(playername));
        format(SM_PNstring, sizeof(SM_PNstring), "*** %s 's Weapons in Hand: %s", playername, ReturnPlayerWeaponsString(checkid));
        SendClientMessage(playerid, 0xFF8000FF, SM_PNstring);
    }
    else SendClientMessage(playerid, 0xAFAFAFAA, "USAGE: /check [playerid/PartofName]");
    return 1;
}
Good Luck. Untested.
Reply
#9

Quote:
Originally Posted by [B2K
Hustler ]
Here, I've adapted something from my script to work for your /check command:

pawn Код:
new wNamesShortened[][32] = {
    {"Unarmed (Fist)"}, // 0
    {"Brass Knuckles"}, // 1
    {"Golf Club"}, // 2
    {"Night Stick"}, // 3
    {"Kn."}, // 4
    {"Baseball Bat"}, // 5
    {"Shovel"}, // 6
    {"Pool Cue"}, // 7
    {"Katana"}, // 8
    {"Chainsaw"}, // 9
    {"Purple Dildo"}, // 10
    {"Big White Vibrator"}, // 11
    {"Medium White Vibrator"}, // 12
    {"Small White Vibrator"}, // 13
    {"Flowers"}, // 14
    {"Cane"}, // 15
    {"Grenade"}, // 16
    {"Teargas"}, // 17
    {"Molotov"}, // 18
    {" "}, // 19
    {" "}, // 20
    {" "}, // 21
    {"Colt 45"}, // 22
    {"Silenced"}, // 23
    {"Deagle"}, // 24
    {"Shotgun"}, // 25
    {"Sawnoff"}, // 26
    {"Combat"}, // 27
    {"Uzi"}, // 28
    {"MP5"}, // 29
    {"AK47"}, // 30
    {"M4"}, // 31
    {"Tec9"}, // 32
    {"Rifle"}, // 33
    {"Sniper"}, // 34
    {"RPG"}, // 35
    {"HS RPG"}, // 36
    {"Flamethrower"}, // 37
    {"Minigun"}, // 38
    {"Satchel Charge"}, // 39
    {"Detonator"}, // 40
    {"Spray Can"}, // 41
    {"Fire Extinguisher"}, // 42
    {"Camera"}, // 43
    {"NVG"}, // 44
    {"IVG"}, // 45
    {"Para."}, // 46
    {"Fake Pistol"} // 47
};

stock ReturnPlayerWeaponsString(playerid)
{
    new string[128];
    new WeaponID, Ammo;
    for(new i = 0; i < 13; i++)
    {
      if(i == 0 || i == 1)
        {
            GetPlayerWeaponData(playerid,i,WeaponID,Ammo);
            if(Ammo > 1)
            {
              Ammo = 1;
            }
      }
        else
        {
            GetPlayerWeaponData(playerid,i,WeaponID,Ammo);
        }
        if(WeaponID > 0 && Ammo > 0)
        {
          if(Ammo > 60000) //melee weaps
            Ammo = 1;

          if(strlen(string) > 4)
                format(string,128,"%s %s(%d),", string, wNamesShortened[WeaponID], Ammo);
            else
                format(string,128,"%s(%d),", wNamesShortened[WeaponID], Ammo);//First Weapon
        }
    }
    if(strlen(string) < 3)
    {
        string = "N/A";
    }
    return string;
}

zcmd(check, playerid, params[])
{
    new checkid;
    if (!sscanf(params, "u", checkid))
    {
        if(!IsPlayerConnected(checkid)) return SendClientMessage(playerid, 0xAFAFAFAA, "* That player is not connected.");
        if(checkid == playerid) return SendClientMessage(playerid, 0xAFAFAFAA, "* You cannot check yourself yourself");
        new SM_PNstring [128], playername[MAX_PLAYER_NAME];
        GetPlayerName(checkid,playername,sizeof(playername));
        format(SM_PNstring, sizeof(SM_PNstring), "*** %s 's Weapons in Hand: %s", playername, ReturnPlayerWeaponsString(checkid));
        SendClientMessage(playerid, 0xFF8000FF, SM_PNstring);
    }
    else SendClientMessage(playerid, 0xAFAFAFAA, "USAGE: /check [playerid/PartofName]");
    return 1;
}
Good Luck. Untested.
I am interested to know what I do if string is too long... what you can do then, for example to strip a new line... =/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)