GetPlayerWeaponData Help
#1

I'm making a command that compares the weapon data that a player has to the weapon data their account has (for anti weapon hacking checking), but when I try to show what GetPlayerWeaponData shows, it doesn't work.

pawn Код:
CMD:checkweapons(playerid, params[])
{
    if(GetPVarInt(playerid, "LoggedIn") == 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You need to be logged in to use this command.");
    new string[256], id;
    if(Player[playerid][AdminLevel] >= 2)
    {
        if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_GREY, "[Server Command]: /checkweapons [playerid]");
        new weapons[13][2];
        for(new i=0; i<13; i++)
        {
            GetPlayerWeaponData(id, i, weapons[i][0], weapons[i][1]);
            format(string, sizeof(string), "Slot %i: %i", i, weapons[i][0]);
        }
        ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Player's Client-Side Weapons", string, "OK", "");
        format(string, sizeof(string), "%s's account weapons:", GetName(id));
        SendClientMessage(playerid, COLOR_LIGHTRED, string);
        format(string, sizeof(string), "Slot 1: {FFFFFF}%i{C0C0C0} - Slot 2: {FFFFFF}%i{C0C0C0} - Slot 3: {FFFFFF}%i{C0C0C0} - Slot 4: {FFFFFF}%i{C0C0C0} - Slot 5: {FFFFFF}%i{C0C0C0} - Slot 6: {FFFFFF}%i{C0C0C0}", Player[id][Weapon1], Player[id][Weapon2], Player[id][Weapon3], Player[id][Weapon4], Player[id][Weapon5], Player[id][Weapon6]);
        SendClientMessage(playerid, COLOR_GREY, string);
        format(string, sizeof(string), "Slot 7: {FFFFFF}%i{C0C0C0} - Slot 8: {FFFFFF}%i{C0C0C0} - Slot 9: {FFFFFF}%i{C0C0C0} - Slot 10: {FFFFFF}%i{C0C0C0} - Slot 11: {FFFFFF}%i{C0C0C0} - Slot 12: {FFFFFF}%i{C0C0C0}", Player[id][Weapon7], Player[id][Weapon8], Player[id][Weapon9], Player[id][Weapon10], Player[id][Weapon11], Player[id][Weapon12]);
        SendClientMessage(playerid, COLOR_GREY, string);
        SendClientMessage(playerid, COLOR_LIGHTRED, "Note: If their client-side weapons don't match their account weapons, they are weapon hacking.");
    }
    else return SendClientMessage(playerid, COLOR_GREY, ADMIN);
    return 1;
}
Anyone know what could be wrong?
Reply
#2

Please elaborate on "doesn't work"..
Reply
#3

Код:
for(new i=0; i<13; i++)
		{
		    GetPlayerWeaponData(id, i, weapons[i][0], weapons[i][1]);
		    format(string, sizeof(string), "%sSlot %i: %i",string, i, weapons[i][0]);
		}
Reply
#4

Quote:
Originally Posted by MP2
Посмотреть сообщение
Please elaborate on "doesn't work"..
Instead of showing all weapon slots 0-12, it just shows the first one.
Reply
#5

pawn Код:
CMD:checkweapons(playerid, params[])
{
    if(!GetPVarInt(playerid, "LoggedIn")) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You need to be logged in to use this command.");
    if(Player[playerid][AdminLevel] < 2) return SendClientMessage(playerid, COLOR_GREY, ADMIN);
    new id;
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_GREY, "[Server Command]: /checkweapons [playerid]");
    if(!IsPlayerConnected(id) || id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: That player is not connected.");
    new weapons[13][2], string[150];
    for(new i = 0; i < 13; i++)
    {
        new fstr[12];
        GetPlayerWeaponData(id, i, weapons[i][0], weapons[i][1]);
        if(weapons[i][0])
        {
            format(fstr, sizeof(fstr), "Slot %i: %i\n", i, weapons[i][0]);
            strcat(string, fstr);
        }
    }
    ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Player's Client-Side Weapons", string, "OK", "");
    format(string, sizeof(string), "%s's account weapons:", GetName(id));
    SendClientMessage(playerid, COLOR_LIGHTRED, string);
    format(string, sizeof(string), "{C0C0C0}Slot 1: {FFFFFF}%i{C0C0C0} - Slot 2: {FFFFFF}%i{C0C0C0} - Slot 3: {FFFFFF}%i", Player[id][Weapon1], Player[id][Weapon2], Player[id][Weapon3]);
    SendClientMessage(playerid, COLOR_GREY, string);
    format(string, sizeof(string), "{C0C0C0}Slot 4: {FFFFFF}%i{C0C0C0} - Slot 5: {FFFFFF}%i{C0C0C0} - Slot 6: {FFFFFF}%i", Player[id][Weapon4], Player[id][Weapon5], Player[id][Weapon6]);
    SendClientMessage(playerid, COLOR_GREY, string);
    format(string, sizeof(string), "{C0C0C0}Slot 7: {FFFFFF}%i{C0C0C0} - Slot 8: {FFFFFF}%i{C0C0C0} - Slot 9: {FFFFFF}%i", Player[id][Weapon7], Player[id][Weapon8], Player[id][Weapon9]);
    SendClientMessage(playerid, COLOR_GREY, string);
    format(string, sizeof(string), "{C0C0C0}Slot 10: {FFFFFF}%i{C0C0C0} - Slot 11: {FFFFFF}%i{C0C0C0} - Slot 12: {FFFFFF}%i", Player[id][Weapon10], Player[id][Weapon11], Player[id][Weapon12]);
    SendClientMessage(playerid, COLOR_GREY, string);
    SendClientMessage(playerid, COLOR_LIGHTRED, "Note: If their client-side weapons don't match their account weapons, they are weapon hacking.");
    return 1;
}
References:
https://sampwiki.blast.hk/wiki/Strcat
https://sampwiki.blast.hk/wiki/Format
https://sampwiki.blast.hk/wiki/Keywords:Statements#for

EDIT:

Also, I recommend that you use arrays for your player weapons instead of all those different elements... like Weapon1, Weapon2, Weapon3 etc.

'enum blahblah
{
Weapon[13]
//blah blah...
}'
Reply
#6

This function GetPlayerWeaponData() is fairly unreliable because the client can easily send incorrect data to the server.

What I suggest is using OnPlayerWeaponShot() to keep track of a players ammo then set their ammo if it is more than it is supposed to be and report them.
Reply
#7

Quote:
Originally Posted by Pottus
Посмотреть сообщение
This function GetPlayerWeaponData() is fairly unreliable because the client can easily send incorrect data to the server.
This is so correct, i was facing some guys that were able to completely NOP sending data via this function and able to bypass the AC system.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)