PDA

View Full Version : Weap Restrist


MagicShot
03-12-2004, 21:28
I need some help I am working on a rewrite of my weap script that was like 5500 lines coded out.. I knew I could shorten it..

Thanx to Bailopan's Guildence I begun at work a few mins ago....

I was wondering will this work?


new max_weap_rest[35]
new curweap[35]
new weap_pend[35]
new weap_disabled[35]
new weap_msg[99]
new weap_msg[usp] = "[AMX] Set Weapon USP Disabled Mode"
new bool:first_time = false


public checkweap(id,level,cid) {
new arg[32]
read_argv(1,arg,31)
weap = read_argv(1,arg,31)

if (!curweap[weap]) {
set_hudmessage(0, 100, 0, -1.0, 0.65, 2, 0.02, 10.0, 0.01, 0.1, 2)
show_hudmessage(0,"Weapon Name Not Found!")
return PLUGIN_HANDLED
}
if(weap_disabled[weap] == 0) {
first_time = true
weap_pend[weap] = 1
client_print(id,print_console," weap_msg[weap] ")
}else {
weap_pend[weap] = 2
client_print(id,print_console," weap_msg[weap] ")
}
return PLUGIN_HANDLED
}


Thanx Much...

MagicShot
03-13-2004, 14:29
*bump .. anyone?

SidLuke
03-13-2004, 18:56
new weap_msg[99]
new weap_msg[usp] = "[AMX] Set Weapon USP Disabled Mode"

:?:

client_print(id,print_console," weap_msg[weap] ")

:?:

MagicShot
03-13-2004, 19:01
new weap_msg[99]
new weap_msg[usp] = "[AMX] Set Weapon USP Disabled Mode"

:?:

client_print(id,print_console," weap_msg[weap] ")

:?:

weap_msg[usp] = messges for what restriction I am doing
weap = usp
weap_msg[weap] = deiplays message for weap

SidLuke
03-13-2004, 19:07
weap_msg[usp] = messges for what restriction I am doing
weap = usp
weap_msg[weap] = deiplays message for weap


I still don't get it ..
waep_msg[usp] - this field has message about USP ?
weap_msg[m4a1] - this field has message about M4A1 ?

SidLuke
03-13-2004, 19:11
new weap_msg[99]
new weap_msg[usp] = "[AMX] Set Weapon USP Disabled Mode"

should be

#define CSMAX_WEAPONS 30 + 1
#define MAX_MSGLEN 64
new weap_msg[CSMAX_WEAPONS][MAX_MSGLEN]
new weap_msg[usp][] = "[AMX] Set Weapon USP Disabled Mode"



client_print(id,print_console," weap_msg[weap] ")

should be

client_print(id,print_console,"%s",weap_msg[weap] )

tnsk8er27
03-14-2004, 14:48
gogogogo magicshot :D (i have no idea what that stuff does or means LOL)

MagicShot
03-14-2004, 15:40
Thanx..


weap_msg[usp] = messges for what restriction I am doing
weap = usp
weap_msg[weap] = deiplays message for weap


I still don't get it ..
waep_msg[usp] - this field has message about USP ?
weap_msg[m4a1] - this field has message about M4A1 ?

waep_msg[usp] <- If that is = 1 it is enabled if 0 disasbled

weap_msg[weap] <- used to call usp where if curweapon is usp where weap = Curweapon player is holding

Make more sense?

MagicShot
03-14-2004, 15:59
Will this work?


#include <amxmodx>
#include <amxmisc>

#define CSMAX_WEAPONS 30 + 1
#define MAX_MSGLEN 64

new max_weap_rest[35]
new curweap[35]
new weap_pend[] = usp, deagle, elite, p228, fiveseven
new weap_disabled[] = usp, deagle, elite, p228, fiveseven
new weap_msg[CSMAX_WEAPONS][MAX_MSGLEN]
new weap_msg[usp][] = "[AMX] Set Weapon USP Disabled Mode"

new bool:first_time = false


public checkweap(id,level,cid) {
new arg[32]
read_argv(1,arg,31)
weap = read_argv(1,arg,31)

if (!curweap[weap]) {
set_hudmessage(0, 100, 0, -1.0, 0.65, 2, 0.02, 10.0, 0.01, 0.1, 2)
show_hudmessage(0,"Weapon Name Not Found!")
return PLUGIN_HANDLED
}
if(weap_disabled[weap] == 0) {
first_time = true
weap_pend[weap] = 1
client_print(id,print_console,"%s",weap_msg[weap] )
}else {
weap_pend[weap] = 2
client_print(id,print_console,"%s",weap_msg[weap] )
}
return PLUGIN_HANDLED
}

public plugin_init() {
register_plugin("Weapon Vote and Restrict","0.1","MagicShot")
register_cvar("amx_weaponrest","1",0)
register_clcmd("amx_magrest","checkweap",ADMIN_LEVEL_H,"amx_magrest : toggles restricted weapons eg. amx_magrest weaponname")
}

tnsk8er27
03-14-2004, 16:19
ahh i dont understand!!!!!!!!!!!!!!!!

_KaszpiR_
03-16-2004, 03:41
ahh i dont understand!!!!!!!!!!!!!!!!
so at least stop posting useless posts

_KaszpiR_
03-16-2004, 03:44
MagicShot, as i said on irc
you may use

if(weap_disabled[weap])
{
first_time = true
weap_pend[weap] = 1
client_print(id,print_console," weap_msg[weap] ")
}else
{
weap_pend[weap] = 2
client_print(id,print_console," weap_msg[weap] ")
}

isntead of current code, a bit faster

also the weap_pend make a bool instead of int especially if it is a switch (or you may depcrecate the array and use a bitshifting)


also
09:40:26 (SniperBot) (MagicShot) when I do this
09:40:28 (SniperBot) (MagicShot) new weap_msg[CSMAX_WEAPONS][MAX_MSGLEN]
09:40:28 (SniperBot) (MagicShot) new weap_msg[usp][] = "[AMX] Set Weapon USP Disabled Mode"
09:40:39 (SniperBot) (MagicShot) it says weap_msg already defined


uou use new twice, the first with MAX values and the second you try to define array with a specified value
just remove the new in the second line and it should work

finally
decide if you use weap_msg["usp"] or weap_msg[usp]
as i understanded it on irc you want to parse a string so

but then the currweap is wrong anw the weap = read_argv is wrong
cause it should be at least
new weap[32]
read_argv(1,weap,31)

MagicShot
03-16-2004, 04:09
#include <amxmodx>
#include <amxmisc>

#define CSMAX_WEAPONS 30 + 1
#define MAX_MSGLEN 64

new weap_pend[5]
new weap_disabled[64]
new weap_msg[32][64]
weap_msg["usp"] = "[AMX] Set Weapon USP Disabled Mode"


// new bool:first_time = false


public checkweap(id,level,cid) {
new weap[32]
read_argv(1,weap,31)
weap = read_argv(1,weap,31)

if(weap_disabled[weap]) {
// first_time = true
weap_pend[weap] = 1
client_print(id,print_console,"%s",weap_msg[weap] )
}else {
weap_pend[weap] = 2
client_print(id,print_console,"%s", 2 )
}
return PLUGIN_HANDLED
}

public plugin_init() {
register_plugin("Weapon Vote and Restrict","0.1","MagicShot")
register_cvar("amx_weaponrest","1",0)
register_clcmd("amx_magrest","checkweap",ADMIN_LEVEL_H,"amx_magrest : toggles restricted weapons eg. amx_magrest weaponname")
}

The Compler Give me these errors:

Small compiler 2.1.0 Copyright (c) 1997-2002, ITB CompuPhase

new.sma(10) : error 010: invalid function or declaration
new.sma(19 -- 21) : error 033: array must be indexed (variable "weap")
new.sma(21) : error 033: array must be indexed (variable "weap")
new.sma(23) : error 033: array must be indexed (variable "weap")
new.sma(24) : error 033: array must be indexed (variable "weap")
new.sma(26) : error 033: array must be indexed (variable "weap")

6 Errors.

XAD
03-16-2004, 05:14
I need some help I am working on a rewrite of my weap script that was like 5500 lines coded out.. I knew I could shorten it.
MagicShot, is there anything special with your version of weapon restrict compared to the default in AMXmod?? Or is this only an exercise to learn Small??

/X

MagicShot
03-16-2004, 12:56
I need some help I am working on a rewrite of my weap script that was like 5500 lines coded out.. I knew I could shorten it.
MagicShot, is there anything special with your version of weapon restrict compared to the default in AMXmod?? Or is this only an exercise to learn Small??

/X

Actually Both... Its different from weapon restrist because if your playing a map and want to have just a certain gun it wont even let u pick it up, the 5500 liner works it just too long and I wanna learn small better.. :lol:

pr0*killa
03-16-2004, 14:00
chatty! 8)

MagicShot
03-19-2004, 00:16
Compiles with no Errors?
What am I not Seeing?
Hmm Enabling Weapongs dont work.. argh!



#include <amxmodx>
#include <amxmisc>
#include <string>

// #define CSMAX_WEAPONS 30 + 1 // ** Future Feature **
// #define AMX_MOD // ** Future Feature **
new MsgControl = 0

// new weaponname[29][] = {"usp", "glock", "deagle", "p228" , "elites" , "fiveseven" , "pistols" , "pump" , "auto" , "shotguns" , "mac10" , "ump45" , "mp5" , "tmp", "p90" , "submachinegun" , "ak47" , "sg552" , "colt" , "aug" , "scout" , "awp" , "g3sniper" , "sgsniper" , "zoomed" , "scoped", "zoomscope" , "rifles" , "para"} // ** Old Weapons Aray **

new weaponname[31][] = {"pistols", "p228", "shotguns", "scout", "submachineguns", "auto", "zoomed", "mac10", "aug", "scoped", "elites", "fiveseven", "ump45", "sgsniper", "zoomscope", "rifles", "usp", "glock", "awp", "mp5", "para", "pump", "colt", "tmp", "g3sniper", "25", "deagle", "sg552", "ak47", "knife", "p90"}
new weap_disabled[64]
new weap_pend[32]
new curweap

new bool:first_time = false



public checkweap(id,level,cid) {
// client_print(id,print_console,"[Debug] Running CheckWeap" ) // ** [Debug] Feature **
new weap[32]
read_argv(1,weap,31)
new i = 0
while (++i <= 31) {
// client_print(id, print_console, "wpname=^"%s^", weap=^"%s^"", weaponname[i], weap) // ** [Debug] Feature **
if (containi(weaponname[i], weap)!=-1)
{
curweap = i
}
}


if (weap_disabled[curweap] == 0) {
first_time = true
weap_pend[curweap] = 1
client_print(id,print_console,"%s", curweap )
client_print(id,print_console,"%s", weaponname[curweap][0] )
}else {
weap_pend[curweap] = 2
client_print(id,print_console,"%s", curweap )
client_print(id,print_console,"%s", weap_pend[curweap] )
}
return PLUGIN_HANDLED
}


public dropthatweapon(id) {
new weapon, ammo, wep
weapon = get_user_weapon(id,wep,ammo)
new wepi = read_data(2)
client_print(id,print_console,"[DEBUG] FDrop That Weap Ran")

if (get_cvar_num("amx_weaponrest") == 0)
return PLUGIN_HANDLED

if(first_time == true) {
client_print(id,print_console,"[DEBUG] First Time Ran")
return PLUGIN_HANDLED
}
if (weap_disabled[wepi] == 1) {
if (weap_pend[wepi] == 1 || weap_pend[wepi] == 2 ) {
client_print(id,print_chat,"[AMX] Hey butterfingers! Dont waste your time and money. That Weapon is Disabled")
weapon = get_user_weapon(id,wep,ammo)
// console_print(id,"[DEBUG] weapon: %d, wep: %d, ammo: %d", weapon,wep,ammo) // ** [Debug] Feature **
disarm_player(id,weapon)
}
}
return PLUGIN_HANDLED
}

public RestartRoundTask() {
if (get_cvar_num("amx_weaponrest") == 0)
return PLUGIN_HANDLED

MsgControl = 0
server_print("[AMX] Restarted Round Commands")
set_task(0.2,"delayed_rs")
return PLUGIN_CONTINUE
}

disarm_player(victim, weapon){
new wpname[32]
new parm[2]
parm[0]=victim
get_weaponname(weapon,wpname,31)
engclient_cmd(victim,"drop",wpname)
return PLUGIN_CONTINUE
}

public roundend_cleanup(){
if (get_cvar_num("amx_weaponrest") == 0)
return PLUGIN_HANDLED

MsgControl = 0
return PLUGIN_CONTINUE
}

public round_start(){
if (get_cvar_num("amx_weaponrest") == 0)
return PLUGIN_HANDLED

set_task(0.2,"delayed_rs")
return PLUGIN_CONTINUE
}

public delayed_rs(){
if (get_cvar_num("amx_weaponrest") == 0)
return PLUGIN_HANDLED

if(MsgControl == 1){
server_print("[AMX] MsgControl is 1 Plugin Handled")
return PLUGIN_HANDLED
}
MsgControl = 1

if(first_time == true){
set_hudmessage(63,187,239, -1.0, 0.47, 2, 0.02, 4.5, 0.01, 0.1, 4)
first_time = false
}else{
set_hudmessage(63,187,239, -1.0, 0.73, 2, 0.02, 4.5, 0.01, 0.1, 4)
}
new j
while (j++ <= 31) {
if (weap_pend[j] == 2) {
weap_pend[j] = 1
weap_disabled[j] = 0
}
}
new k
while (k++ <= 31) {
if (weap_pend[k] == 1) {
weap_pend[k] = 1
weap_disabled[k] = 1
}
}
return PLUGIN_CONTINUE
}

public plugin_init() {
register_plugin("Weapon Vote and Restrict","0.1","MagicShot")
register_cvar("amx_weaponrest","1",0)
// register_cvar("amx_weaponwait","1",0) ** Future Feature **
register_cvar("amx_xtra_wep_msg","1")
register_clcmd("amx_magrest","checkweap",ADMIN_USER,"amx_magrest : toggles restricted weapons eg. amx_magrest weaponname")

register_event("CurWeapon","dropthatweapon","b","1=1")
register_event("TextMsg","RestartRoundTask","a","2&#Game_will_restart_in")
register_event("SendAudio","round_start","bc","2=%!MRAD_GO","2=%!MRAD_MOVEOUT","2=%!MRAD_LETSGO","2=%!MRAD_LOCKNLOAD")
register_event("SendAudio","roundend_cleanup","a","2=%!MRAD_terwin","2=%!MRAD_ctwin","2=%!MRAD_rounddraw")
}

_KaszpiR_
03-19-2004, 06:40
see this nearline 47

for (i=0; i<=32; i++) {


and see this near line 11

new weaponname[29][] = {"usp", "glock", "deagle", "p228" , "elites" , "fiveseven" , "pistols" , "pump" , "auto" , "shotguns" , "mac10" , "ump45" , "mp5" , "tmp", "p90" , "submachinegun" , "ak47" , "sg552" , "colt" , "aug" , "scout" , "awp" , "g3sniper" , "sgsniper" , "zoomed" , "scoped", "zoomscope" , "rifles" , "para"}


you are riding out of the array size, the i should be max 29 (sorta... :P)

thats why i suggest using while ( ) statement

MagicShot
03-19-2004, 13:17
see this nearline 47

for (i=0; i<=32; i++) {


and see this near line 11

new weaponname[29][] = {"usp", "glock", "deagle", "p228" , "elites" , "fiveseven" , "pistols" , "pump" , "auto" , "shotguns" , "mac10" , "ump45" , "mp5" , "tmp", "p90" , "submachinegun" , "ak47" , "sg552" , "colt" , "aug" , "scout" , "awp" , "g3sniper" , "sgsniper" , "zoomed" , "scoped", "zoomscope" , "rifles" , "para"}


you are riding out of the array size, the i should be max 29 (sorta... :P)

thats why i suggest using while ( ) statement

How Does this Look? Above was edited with this also..
Does anyone see anythinf else?


weapname() {
new i = 0
while (i++ < 29) {
if (weaponname[i][0] == weap) {
curweap = i
return PLUGIN_CONTINUE
}
}
return PLUGIN_CONTINUE
}

MagicShot
03-20-2004, 07:13
Ok Here Is what I have So far..
I can't seem to get the bool:first_time to work right

bool:first_time[32]


#include <amxmodx>
#include <amxmisc>
#include <string>

new MsgControl = 0
new const weaponname[31][] = {"pistols", "p228", "shotguns", "scout", "submachineguns", "auto", "zoomed", "mac10", "aug", "scoped", "elites", "fiveseven", "ump45", "sgsniper", "zoomscope", "rifles", "usp", "glock", "awp", "mp5", "para", "pump", "colt", "tmp", "g3sniper", "25", "deagle", "sg552", "ak47", "knife", "p90"}
new weap_disabled[64]
new weap_pend[32]
new curweap
// new bool:first_time = false
new bool:first_time[32]



public checkweap(id,level,cid) {
new weap[32]
read_argv(1,weap,31)
new i = 0
while (++i <= 31) {
if (containi(weaponname[i], weap)!=-1) {
curweap = i
client_print(id, print_console, "wpname=^"%s^", weap=^"%s^", inc=^"%s^"", weaponname[i], weap, curweap)
}
}
if (weap_disabled[curweap] == 0) {
first_time[curweap] = true
weap_pend[curweap] = 1
client_print(id,print_console,"[DEBUG] Disable Weaps Next Round")
}else {
weap_pend[curweap] = 2
client_print(id,print_console,"[DEBUG] Enable Weaps Next Round")
}
return PLUGIN_HANDLED
}


public dropthatweapon(id) {
new weapon, ammo, wep
weapon = get_user_weapon(id,wep,ammo)
new const wepi = read_data(2)

if (get_cvar_num("amx_weaponrest") == 0)
return PLUGIN_HANDLED

if(first_time[wepi] == true) {
client_print(id,print_console,"[DEBUG] First Time Ran")
return PLUGIN_HANDLED
}

if (weap_disabled[wepi] == 1) {
// if (weap_pend[wepi] == 1) || (weap_pend[wepi] == 2) {
client_print(id,print_chat,"[AMX] Hey butterfingers! Dont waste your time and money. That Weapon is Disabled")
weapon = get_user_weapon(id,wep,ammo)
// console_print(id,"[DEBUG] weapon: %d, wep: %d, ammo: %d", weapon,wep,ammo) // ** [Debug] Feature **
disarm_player(id,weapon)
}
return PLUGIN_HANDLED
}

public RestartRoundTask() {
if (get_cvar_num("amx_weaponrest") == 0)
return PLUGIN_HANDLED

MsgControl = 0
set_task(0.2,"delayed_rs")
return PLUGIN_CONTINUE
}

disarm_player(victim, weapon){
new wpname[32]
new parm[2]
parm[0]=victim
get_weaponname(weapon,wpname,31)
engclient_cmd(victim,"drop",wpname)
return PLUGIN_CONTINUE
}

public roundend_cleanup(){
if (get_cvar_num("amx_weaponrest") == 0)
return PLUGIN_HANDLED

MsgControl = 0
return PLUGIN_CONTINUE
}

public round_start(){
if (get_cvar_num("amx_weaponrest") == 0)
return PLUGIN_HANDLED

MsgControl = 0
set_task(0.2,"delayed_rs")
return PLUGIN_CONTINUE
}

public delayed_rs(id){

if (get_cvar_num("amx_weaponrest") == 0)
return PLUGIN_HANDLED

if(MsgControl == 1){
return PLUGIN_HANDLED
}

MsgControl = 1
new h = 0
while (h++ <= 31) {
if (first_time[h] == true) {
set_hudmessage(63,187,239, -1.0, 0.47, 2, 0.02, 4.5, 0.01, 0.1, 4)
first_time[h] = false
}
}
/*
else{
set_hudmessage(63,187,239, -1.0, 0.73, 2, 0.02, 4.5, 0.01, 0.1, 4)
}
*/
new j = 0
while (j++ <= 31) {
if ( (weap_pend[j] == 2) && (weap_disabled[j] == 1) ){
weap_pend[j] = 0
weap_disabled[j] = 0
//client_print(id, print_console, "wp_pend=^"%s^", weap_disabled=^"%s^"", weap_pend[16], weap_disabled[16])
}else if (weap_pend[j] == 1) {
weap_disabled[j] = 1
//client_print(id, print_console, "wp_pend=^"%s^", weap_disabled=^"%s^"", weap_pend[j], weap_disabled[j])
}

}
/*
new k = 0
while (k++ <= 31) {
if (weap_pend[k] == 1) {
weap_pend[k] = 2
weap_disabled[k] = 1
client_print(id, print_console, "wp_pend=^"%s^", weap_disabled=^"%s^"", weap_pend[k], weap_disabled[k])
}
*/
return PLUGIN_CONTINUE
}

public plugin_init() {
register_plugin("Weapon Vote and Restrict","0.1","MagicShot")
register_cvar("amx_weaponrest","1",0)
register_cvar("amx_xtra_wep_msg","1")
register_clcmd("amx_magrest","checkweap",ADMIN_USER,"amx_magrest : toggles restricted weapons eg. amx_magrest weaponname")

register_event("CurWeapon","dropthatweapon","b","1=1")
register_event("TextMsg","RestartRoundTask","a","2&#Game_will_restart_in")
register_event("SendAudio","round_start","bc","2=%!MRAD_GO","2=%!MRAD_MOVEOUT","2=%!MRAD_LETSGO","2=%!MRAD_LOCKNLOAD")
register_event("SendAudio","roundend_cleanup","a","2=%!MRAD_terwin","2=%!MRAD_ctwin","2=%!MRAD_rounddraw")
}

_KaszpiR_
03-22-2004, 04:45
hmm , the arrays amybe can contain integers or strings only???

try using intenegrs then, it will be a but more resurce consuming

MagicShot
03-22-2004, 17:58
Thanx Kas.. I got it figured out..

I posted the Plugin in the plugins section..
The Base is there but working on voting system this week..

Credits to Kas and Bail for there wonderful assistance and helping me understanding arrays and loops & while statements.. :D

IceMouse[WrG]
03-22-2004, 18:05
#include <amxmodx>
#include <amxmisc>

#define CSMAX_WEAPONS 30 + 1
#define MAX_MSGLEN 64

new max_weap_rest[35]
new curweap[35]
new weap_pend[] = usp, deagle, elite, p228, fiveseven
new weap_disabled[] = usp, deagle, elite, p228, fiveseven
new weap_msg[CSMAX_WEAPONS][MAX_MSGLEN]
new weap_msg[CSW_USP][] = "[AMX] Set Weapon USP Disabled Mode"

new bool:first_time = false


public checkweap(id,level,cid) {
new arg[32]
read_argv(1,arg,31)
weap = read_argv(1,arg,31)

if (!curweap[weap]) {
set_hudmessage(0, 100, 0, -1.0, 0.65, 2, 0.02, 10.0, 0.01, 0.1, 2)
show_hudmessage(0,"Weapon Name Not Found!")
return PLUGIN_HANDLED
}
if(weap_disabled[weap] == 0) {
first_time = true
weap_pend[weap] = 1
client_print(id,print_console,weap_msg[weap] ) //Should work...
}else {
weap_pend[weap] = 2
client_print(id,print_console,weap_msg[weap] ) //Same
}
return PLUGIN_HANDLED
}

public plugin_init() {
register_plugin("Weapon Vote and Restrict","0.1","MagicShot")
register_cvar("amx_weaponrest","1",0)
register_clcmd("amx_magrest","checkweap",ADMIN_LEVEL_H,"amx_magrest : toggles restricted weapons eg. amx_magrest weaponname")
}

_KaszpiR_
03-23-2004, 02:30
about voting system, maybe another plugin can ccoerate with that - i use one plugin that really heps in such a strange things, but i forgot the name (sth like admin vote? or vote system.. dunno)