Help with my simple anti cheat :D
#1

pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    new weapname[32], weapname2[32], string[32];
    GetWeaponName(weaponid, weapname, sizeof(weapname));
    format(string, sizeof(string), "%s", weapname);
    if(GetPVarString(playerid, "Weapon", weapname2, sizeof(weapname2)) != string) return SCM(playerid, -1, "Hello Hacker");
    return 1;
}
So i get this error:
error 033: array must be indexed (variable "string")

basiacally what i do is when my script gives someone a weapon, i set pvarstring on him for the weapon name, now on shot i want to detect it but how to match those strings, i keep getting same error

thanks
Reply
#2

You can't just simply compare a string of that way:

PHP код:
if(GetPVarString(playerid"Weapon"weapname2sizeof(weapname2)) != string
You could use strcmp.
https://sampwiki.blast.hk/wiki/Strcmp
Reply
#3

Quote:
Originally Posted by ThePhenix
Посмотреть сообщение
You can't just simply compare a string of that way:

PHP код:
if(GetPVarString(playerid"Weapon"weapname2sizeof(weapname2)) != string
You could use strcmp.
actually im not good with strcmp, can u help me? plz
Reply
#4

pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    new weapname[32], weapname2[32];
    GetWeaponName(weaponid, weapname, sizeof(weapname));
    GetPVarString(playerid, "Weapon", weapname2, sizeof(weapname2));
    if (!strcmp(weapname, weapname2, true)) return SCM(playerid, -1, "Hello Hacker");
    return 1;
}
Reply
#5

Quote:
Originally Posted by Stinged
Посмотреть сообщение
pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    new weapname[32], weapname2[32];
    GetWeaponName(weaponid, weapname, sizeof(weapname));
    GetPVarString(playerid, "Weapon", weapname2, sizeof(weapname2));
    if (!strcmp(weapname, weapname2, true)) return SCM(playerid, -1, "Hello Hacker");
    return 1;
}
I found another way to do, it is better

But thanks a lot for your help, you really made me understand how to match strings! thanks!! +rep'ed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)