1 problem
#1

i have this command but given me 1 warning.can you fix it?
Код:
#include <a_samp>

#define COLOR_RED 0xFF0000AA

new ForbiddenWeapons[][] = {
38,
35,
36
};

public OnPlayerUpdate(playerid)
{
    new pName[MAX_PLAYER_NAME],
        w = 0,
        string[128];
    if(GetPlayerMoney(playerid) > pMoney[playerid]){
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "* %s has been banned: MONEY CHEAT", pName);
        SendClientMessageToAll(COLOR_RED, string);
        BanEx(playerid, "Money Cheat");
    }
    while(w < (sizeof(ForbiddenWeapons))){
        if(GetPlayerWeapon(playerid) == w){
            GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
            format(string, sizeof(string), "* %s has been banned: WEAPON CHEAT", pName);
            SendClientMessageToAll(COLOR_RED, string);
            BanEx(playerid, "Weapon Cheat");
        }
    }
    return 1;
}
Код:
C:\Users\Aref\Desktop\Aref\sampserver\pawno\CODv2.pwn(1871) : warning 203: symbol is never used: "ForbiddenWeapons"
Reply
#2

ForbiddenWeapons is only used for the sake of determining the array size and sizeof does not run actively within that callback but rather on compile and as such it will be seen as unused. Rather replace it with the array size (best practice) or else use
Код:
#pragma unused ForbiddenWeapons
if you aren't ever going to use the array for anything else (but that seems like such a waste)
Reply
#3

1. It does not need to be a two dimensional array, remove the second set of square braces.
2. To loop over the array, use:
PHP код:
for(new isizeof(ForbiddenWeapons); i++)
{
    if(
GetPlayerWeapon(playerid) == ForbiddenWeapons[i])
    {
        
// stuff
    
}

Remember: you want to check the value of the index, not the index itself.
Reply
#4

what is this code problem i saw this:

Код:
{
        if(GetPlayerWeapon(playerid) == 38 || 35)
		{
		    if(PlayerInfo[playerid][pAdmin] !=2)
		    {
	            GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
	           	format(string, sizeof(string), "[SERVERANTICHEAT]%s (id:%d) may be the weapon cheat.check him.", pName, playerid);
	            SendWarnMessageToAdmins(string);
            }
        }
    }
Reply
#5

Hello!

PHP код:
if(GetPlayerWeapon(playerid) == 38 || 35)
{
    if(
PlayerInfo[playerid][pAdmin] !=2)
     {
          
GetPlayerName(playeridpNameMAX_PLAYER_NAME);
        
format(stringsizeof(string), "[SERVERANTICHEAT]%s (id:%d) may be the weapon cheat.check him."pNameplayerid);
          
SendWarnMessageToAdmins(string);
        break;
      }

Reply
#6

Код:
C:\Users\Aref\Desktop\Aref\sampserver\pawno\CODv2.pwn(1772) : error 024: "break" or "continue" is out of context
Reply
#7

PHP код:
if(GetPlayerWeapon(playerid) == 38 || 35

    if(
PlayerInfo[playerid][pAdmin] !=2
     { 
          
GetPlayerName(playeridpNameMAX_PLAYER_NAME); 
        
format(stringsizeof(string), "[SERVERANTICHEAT]%s (id:%d) may be the weapon cheat.check him."pNameplayerid); 
          
SendWarnMessageToAdmins(string); 
        return 
1
      } 

Reply
#8

You are using this function to OnPlayerUpdate... it will send this message every milisecond. Also if you want to make an anticheat i suggest you to use a timer for that since it will lag your server if you get more than 5 players.
Reply
#9

not works.
Код:
if(GetPlayerWeapon(playerid) == 38 || GetPlayerWeapon(playerid) == 35)
	{
	    if(PlayerInfo[playerid][pAdmin] < 2)
    	{
     		SetTimer("weaponanticheat", 5000, false);
     	}
	}
forward weaponanticheat(playerid);
public weaponanticheat(playerid)
{
    new pName[MAX_PLAYER_NAME],
    string[128];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
	format(string, sizeof(string), "[SERVERANTICHEAT]%s (id:%d) may be the weapon cheat.check him.", pName, playerid);
   	SendWarnMessageToAdmins(string);
    return 1;
}
Reply
#10

PHP код:
SetTimer("weaponanticheat"5000false); 
to
PHP код:
SetTimerEx("weaponanticheat"5000false,"i",playerid); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)