Anti Guns -
Serifukas - 10.08.2011
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?
Re: Anti Guns -
ylleron - 10.08.2011
i don't know why did you resetplayer weapons if you will kick him
I'm gonna test it
EDIT: / try
change to
Re: Anti Guns -
Riddick94 - 10.08.2011
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;
}
Re: Anti Guns -
ylleron - 10.08.2011
It works for me
http://pastebin.com/z7Qq9FJB
edited: weapon name
-
Serifukas - 10.08.2011
: error 017: undefined symbol "pname"
How to fix it ?
Ylleron On this script i need to use timer in OneGameModeInit ?
Re: Anti Guns -
Riddick94 - 10.08.2011
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.
Re: Anti Guns -
ylleron - 10.08.2011
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;
}
Re: Anti Guns -
Serifukas - 10.08.2011
Don't Work :SSS
Re: Anti Guns -
Riddick94 - 10.08.2011
Then just test it what i sent you?..
Re: Anti Guns -
Serifukas - 10.08.2011
Yes when i connect to the server then automatic kick my
Re: Anti Guns -
Tanush123 - 10.08.2011
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!");
}
Re: Anti Guns -
Serifukas - 11.08.2011
With This Code I Get Errors :
Код:
expected token: ";", but found "=="
error 029: invalid expression, assumed zero
Re: Anti Guns -
Tanush123 - 11.08.2011
can you show me the lines so i could fix it? i cannot see your pawno and find the lines fast to fix it
Re: Anti Guns -
Serifukas - 11.08.2011
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;
}
Re: Anti Guns -
MadeMan - 11.08.2011
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);
}
}
}
}
Re: Anti Guns -
Tanush123 - 11.08.2011
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;
}
Re: Anti Guns -
Serifukas - 11.08.2011
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
Re: Anti Guns -
Tanush123 - 12.08.2011
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
Re: Anti Guns -
Serifukas - 13.08.2011
Thanks