Anti Guns
#1

Hello Everybody.

I made anti guns script.
All script look good but then i take minigun nothing happen.

Script Code In GameMode :

Код:
new BadWeapons[3] =
{
    38, 36, 39
};

forward BadCheck();
public BadCheck()
{
  new weap, string[128], pname[MAX_PLAYER_NAME]; 
    for(new i, b = GetMaxPlayers(); i < b; i++) 
    {
      GetPlayerName(i, pname, sizeof(pname));

      weap = GetPlayerWeapon(i);
      for(new w; w < sizeof(BadWeapons); w++)
      {
            if(weap == BadWeapons[w])
            {
                format(string,sizeof(string),"[ Kick ]%s Kicked For %s.", pname, weap);
                SendClientMessageToAll(COLOR_RED,string);
                ResetPlayerWeapons(i);
                Kick(i);
			}
            return 1;
        }
    }
    return 1;
}
And I Added In OneGameModeInit Timer :

Код:
SetTimer("BadCheck",5000,1);
What can be wrong?
Reply
#2

i don't know why did you resetplayer weapons if you will kick him

I'm gonna test it

EDIT: / try

pawn Код:
new i, b = ...
change to

pawn Код:
new i=0, b=...
Reply
#3

Better way:

pawn Код:
#include        "a_samp"

new BadWeapons[3] =
{
    38, 36, 39
};

forward BadCheck();
public BadCheck()
{
    new weapon[13], ammo, string[128];
    for(new i = 0; i < GetMaxPlayers(); i++)if(IsPlayerConnected(i))
    {
        for(new w = 0; w < 13; w++)
        {
            GetPlayerWeaponData(i, w, weapon[w], ammo);
            for(new b = 0; b < sizeof(BadWeapons); b++)
            {
                if(BadWeapons[b] == weapon[w])
                {
                    format(string,sizeof(string),"[ Kick ]%s Kicked For %s.", pname, weap);
                    MessageToAdmins(white,string);
                    ResetPlayerWeapons(i);
                    Kick(i);
                }
            }
        }
    }
    return true;
}
Reply
#4

It works for me

http://pastebin.com/z7Qq9FJB

edited: weapon name
Reply
#5

: error 017: undefined symbol "pname"

How to fix it ?

Ylleron On this script i need to use timer in OneGameModeInit ?
Reply
#6

With my way you don't need to get this weapon at the momment in hands. But how'd you prefer.

pawn Код:
new pname[MAX_PLAYER_NAME];
Yes you need to use a timer.
Reply
#7

i sent you my testing code which worked correct

pawn Код:
#include <a_samp>

// to gamemode ( OnGameModeInit() )
// SetTimer("BadCheck", 1000*5, true);

new BadWeapons[3] =
{
    38, 36, 39
};

forward BadCheck();
public BadCheck()
{
    new weap, string[128], pname[MAX_PLAYER_NAME], weapname[50];
    for(new i=0;i<GetMaxPlayers();i++)
    {
        if (IsPlayerConnected(i))
        {
            GetPlayerName(i, pname, sizeof(pname));
           
            weap = GetPlayerWeapon(i);
            for(new w; w < sizeof(BadWeapons); w++)
            {
                if(weap == BadWeapons[w])
                {
                    GetWeaponName(w, weapname, sizeof(weapname));
                    format(string,sizeof(string), "[ Kick ]%s Kicked For %s.", pname, weapname);
                    SendClientMessageToAll(-1, string);
                    ResetPlayerWeapons(i);
                    Kick(i);
                }
                return 1;
            }
        }
    }
    return 1;
}
Reply
#8

Don't Work :SSS
Reply
#9

Then just test it what i sent you?..
Reply
#10

Yes when i connect to the server then automatic kick my
Reply
#11

OnPlayerUpdate
pawn Код:
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid,Name,sizeof(Name));
new str[128];
new weaponid == GetPlayerWeapon(playerid);
if(weaponid == 38 )
{
            format(str,sizeof(str),"BANBOT: %s has been banned from server for hacking a minigun!",Name);
            SendClientMessageToAll(red,str);
                        BanEx(playerid,"BANBOT: Minigun Hack!");
}
Reply
#12

With This Code I Get Errors :

Код:
 expected token: ";", but found "=="
error 029: invalid expression, assumed zero
Reply
#13

can you show me the lines so i could fix it? i cannot see your pawno and find the lines fast to fix it
Reply
#14

My Pawn Look Like This



CODE :

Код:
public OnPlayerUpdate(playerid){
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid,Name,sizeof(Name));
new str[128];
new weaponid == GetPlayerWeapon(playerid);
if(weaponid == 38 )
{
format(str,sizeof(str),"BANBOT: %s has been banned from server for hacking a minigun!",Name);
SendClientMessageToAll(RED,str);
BanEx(playerid,"BANBOT: Minigun Hack!");
}
return 1;
}
Reply
#15

Remove returns

pawn Код:
public BadCheck()
{
    new weap, string[128], pname[MAX_PLAYER_NAME];
    for(new i, b = GetMaxPlayers(); i < b; i++)
    {
        GetPlayerName(i, pname, sizeof(pname));

        weap = GetPlayerWeapon(i);
        for(new w; w < sizeof(BadWeapons); w++)
        {
            if(weap == BadWeapons[w])
            {
                format(string,sizeof(string),"[ Kick ]%s Kicked For %s.", pname, weap);
                SendClientMessageToAll(COLOR_RED,string);
                Kick(i);
            }
        }
    }
}
Reply
#16

sorry change
pawn Код:
new weaponid == GetPlayerWeapon(playerid);
to
pawn Код:
new weaponid = GetPlayerWeapon(playerid);
line 6825 so
pawn Код:
public OnPlayerUpdate(playerid){
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid,Name,sizeof(Name));
new str[128];
new weaponid = GetPlayerWeapon(playerid);
if(weaponid == 38 )
{
format(str,sizeof(str),"BANBOT: %s has been banned from server for hacking a minigun!",Name);
SendClientMessageToAll(RED,str);
BanEx(playerid,"BANBOT: Minigun Hack!");
}
return 1;
}
Reply
#17

i make code now it look like this :

Код:
public OnPlayerUpdate(playerid){
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid,Name,sizeof(Name));
new str[128];
new weaponid = GetPlayerWeapon(playerid);
if(weaponid == 38 )
{
format(str,sizeof(str),"[Security]: %s Kicked For Guns Hack !",Name);
SendClientMessageToAll(RED,str);
ResetPlayerWeapons(playerid);
Kick(playerid);
}
return 1;
}
Now I have 2 questions..

First question:
How to add this guns ids if player get that guns kick him to like with minigun.

This Is Unlegal Guns Ids :
Код:
 9,  26, 35,  36,  37, 16,  18,  39,  44, 45.
Second question:

How to do when player kick from server remove him weapons.

If you can please help
Reply
#18

no problem serifukas add another line with
pawn Код:
if(weaponid == gunid )
{
format(str,sizeof(str),"[Security]: %s Kicked For Guns Hack !",Name);
SendClientMessageToAll(RED,str);
ResetPlayerWeapons(playerid);
Kick(playerid);
}
Replace gun id with the gun id you wanna add next
Reply
#19

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)