Raised This Month: $ Target: $400
 0% 

Client Cmd registers as CVAR?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Zenith77
Veteran Member
Join Date: Aug 2005
Old 10-22-2005 , 13:32   Client Cmd registers as CVAR?
Reply With Quote #1

Ok i register the command:

Code:
register_clcmd( "amx_pickpocket", "pickpocket", ADMIN_ALL, "Pickpockets the person near you!" )

but when i type it i get

Code:
amx_pickpocket is "0"
This is my full plugin_init()

Code:
public plugin_init() {     register_plugin( "PickPocket", "1.0", "Zenith77" )         register_clcmd( "amx_pickpocket", "pickpocket", ADMIN_ALL, "Pickpockets the person near you!" )         register_cvar( "pp_ppradius", "10" )     register_cvar( "pp_pickamount", "1000" )     register_cvar( "PickPocket", "1" )         register_logevent("Round_Start", 2, "0=World triggered", "1=Round_Start")       }

and the entire code:

Code:
#include <amxmodx> #include <cstrike> new bool:PickPocketed[33][33] /* This array is used to check who pick pockted who. For example: If i am in slot 1 and pick pocet someone in slot 2 I would to PickPocketed[1][2] = true to prevent them from pickpocketing over and over again. */ public plugin_init() {     register_plugin( "PickPocket", "1.0", "Zenith77" )         register_clcmd( "amx_pickpocket", "pickpocket", ADMIN_ALL, "Pickpockets the person near you!" )         register_cvar( "pp_ppradius", "10" )     register_cvar( "pp_pickamount", "1000" )     register_cvar( "PickPocket", "1" )         register_logevent("Round_Start", 2, "0=World triggered", "1=Round_Start")       } public pickpocket(id) {         if( !get_cvar_num("PickPocket") ) {                 client_print(id, print_chat, "[AMXX] Sorry, pick pocketing is disabled ! " )                 return PLUGIN_HANDLED     }         new pocketer_origin[3]     new victim_origin[3]     new pp_radius           pp_radius = get_cvar_num("pp_ppradius")         get_user_origin(id, pocketer_origin)             for( new i = 1; i<get_maxplayers(); i++) {                 if( !is_user_connected(i) ) continue                         if( is_user_alive(id) && is_user_alive(i) && get_user_team(id) != get_user_team(i) ) { // prevents pick pocketing from you own team.. etc                         if( i == id ) return PLUGIN_CONTINUE                         get_user_origin(i, victim_origin)                         new distance = get_distance( pocketer_origin, victim_origin )                         if( distance <= pp_radius ) {                                 if( PickPocketed[id][i] ) {                                         client_print(id, print_chat, "[AMXX] You have already pick pocketed your target! " )                                         return PLUGIN_HANDLED                                     }                                 cs_get_user_money(id)                 cs_get_user_money(i)                 // the above is just so it can "refernce" it                                 //[][][][][][][][][][][][][][][][][][][]                 // the below checks if the victim has no money or if                 // the pick pocketer has 16000 dollars..if so action is cancled!                 if(cs_get_user_money(i) == 0) {                     client_print(id, print_chat, "[AMXX] Your Target has no money for you to take! Go search for someone else!" )                     return PLUGIN_HANDLED                 }                 if(cs_get_user_money(id) == 16000){                     client_print(id, print_chat, "[AMXX] Ok now your just being greedy, you already have the max amount of money [ $16000  ]" )                     return PLUGIN_HANDLED                 }                 //[][][][][][][][][][][][][][][][][][][][]                                                 new amount = get_cvar_num("pp_pickamount")                 new result                 new p_amount // pick pocketer amount of money                 new v_amount // victim amount of money                                 p_amount = cs_get_user_money(id)                 v_amount = cs_get_user_money(i)                                 if(get_cvar_num("pp_pickamount") > v_amount) {                                         new result2                                         // If you will noitce below this one is "equation" is different from the                     // one in the code below...this prevents negative numbers and                     // makes sure that if the vitim has less money than the pp_pickamount cvar                     //it prevents the pickpocketer from getting all the money....                                         result2 = amount - v_amount                                         new amount_pp                     amount_pp = p_amount + result2                                         cs_set_user_money(i, 0, 1)                     cs_set_user_money(id, amount_pp, 1)                                         client_print(i, print_chat, "[AMXX] OH NO! You've been pick pocketed!")                     client_print(id, print_chat, "[AMXX] Congrats on your successful Pick! You never cease to amaze me ;)" )                                         return PLUGIN_HANDLED                 }                                 if(get_cvar_num("pp_pickamount") < v_amount) {                     // once again...do not modify the below....                                         result = v_amount - amount                                         new amount_pp = p_amount + result                                         cs_set_user_money(i, result, 1)                     cs_set_user_money(id, amount_pp, 1)                                         client_print(i, print_chat, "[AMXX] OH NO! You've been pick pocketed!")                     client_print(id, print_chat, "[AMXX] Congrats on your successful Pick! You never cease to amaze me ;)" )                                         return PLUGIN_HANDLED                 }                                 PickPocketed[id][i] = true                             }         }     }     return PLUGIN_HANDLED } public Round_Start() {         /*     Globaly Resets the PickPocketed bool.     */         /*     Debugging:     */         log_amx("Reseting PickPocketing Bool")         new i         for( i = 1; i < get_maxplayers(); i++ ) {                 if( !is_user_connected(i) ) continue                 PickPocketed[i][i] = false             } } public client_connect(id) {         new i         for( i = 1; i < get_maxplayers(); i++) {                 PickPocketed[id][i] = false     } }
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-22-2005 , 19:23  
Reply With Quote #2

Try changing the name of the function pickpocket or the name of the cvar PickPocket.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 10-22-2005 , 19:34  
Reply With Quote #3

Ok i did that, it doesnt act as a cvar anymore,

but now it just doesnt work

It keeps saying unkowncommand, so its like its not even registered.

Code:
#include <amxmodx> #include <cstrike> new bool:PickPocketed[33][33] /* This array is used to check who pick pockted who. For example: If i am in slot 1 and pick pocet someone in slot 2 I would to PickPocketed[1][2] = true to prevent them from pickpocketing over and over again. */ public plugin_init() {     register_plugin( "PickPocket", "1.0", "Zenith77" )         register_clcmd( "amx_pickpocket", "pickpocket", ADMIN_ALL, "Pickpockets the person near you!" )         register_cvar( "pp_ppradius", "10" )     register_cvar( "pp_pickamount", "1000" )     register_cvar( "sv_pickpocket", "1" )         register_logevent("Round_Start", 2, "0=World triggered", "1=Round_Start")       } public pickpocket(id) {         if( !get_cvar_num("sv_pickpocket") ) {                 client_print(id, print_chat, "[AMXX] Sorry, pick pocketing is disabled ! " )                 return PLUGIN_HANDLED     }         new pocketer_origin[3]     new victim_origin[3]     new pp_radius           pp_radius = get_cvar_num("pp_ppradius")         get_user_origin(id, pocketer_origin)             for( new i = 1; i<get_maxplayers(); i++) {                 if( !is_user_connected(i) ) continue                         if( is_user_alive(id) && is_user_alive(i) && get_user_team(id) != get_user_team(i) ) { // prevents pick pocketing from you own team.. etc                         if( i == id ) return PLUGIN_CONTINUE                         get_user_origin(i, victim_origin)                         new distance = get_distance( pocketer_origin, victim_origin )                         if( distance <= pp_radius ) {                                 if( PickPocketed[id][i] ) {                                         client_print(id, print_chat, "[AMXX] You have already pick pocketed your target! " )                                         return PLUGIN_HANDLED                                     }                                 cs_get_user_money(id)                 cs_get_user_money(i)                 // the above is just so it can "refernce" it                                 //[][][][][][][][][][][][][][][][][][][]                 // the below checks if the victim has no money or if                 // the pick pocketer has 16000 dollars..if so action is cancled!                 if(cs_get_user_money(i) == 0) {                     client_print(id, print_chat, "[AMXX] Your Target has no money for you to take! Go search for someone else!" )                     return PLUGIN_HANDLED                 }                 if(cs_get_user_money(id) == 16000){                     client_print(id, print_chat, "[AMXX] Ok now your just being greedy, you already have the max amount of money [ $16000  ]" )                     return PLUGIN_HANDLED                 }                 //[][][][][][][][][][][][][][][][][][][][]                                                 new amount = get_cvar_num("pp_pickamount")                 new result                 new p_amount // pick pocketer amount of money                 new v_amount // victim amount of money                                 p_amount = cs_get_user_money(id)                 v_amount = cs_get_user_money(i)                                 if(get_cvar_num("pp_pickamount") > v_amount) {                                         new result2                                         // If you will noitce below this one is "equation" is different from the                     // one in the code below...this prevents negative numbers and                     // makes sure that if the vitim has less money than the pp_pickamount cvar                     //it prevents the pickpocketer from getting all the money....                                         result2 = amount - v_amount                                         new amount_pp                     amount_pp = p_amount + result2                                         cs_set_user_money(i, 0, 1)                     cs_set_user_money(id, amount_pp, 1)                                         client_print(i, print_chat, "[AMXX] OH NO! You've been pick pocketed!")                     client_print(id, print_chat, "[AMXX] Congrats on your successful Pick! You never cease to amaze me ;)" )                                         PickPocketed[id][i] = true                                         return PLUGIN_HANDLED                 }                                 if(get_cvar_num("pp_pickamount") < v_amount) {                     // once again...do not modify the below....                                         result = v_amount - amount                                         new amount_pp = p_amount + result                                         cs_set_user_money(i, result, 1)                     cs_set_user_money(id, amount_pp, 1)                                         client_print(i, print_chat, "[AMXX] OH NO! You've been pick pocketed!")                     client_print(id, print_chat, "[AMXX] Congrats on your successful Pick! You never cease to amaze me ;)" )                                         PickPocketed[id][i] = true                                         return PLUGIN_HANDLED                 }             }         }     }     return PLUGIN_HANDLED } public Round_Start() {         /*     Globaly Resets the PickPocketed bool.     */         /*     Debugging:     */         log_amx("Reseting PickPocketing Bool")         new i         for( i = 1; i < get_maxplayers(); i++ ) {                 if( !is_user_connected(i) ) continue                 new i2                 for( i2 = 1; i2 <get_maxplayers(); i++ ) {                     PickPocketed[i][i2] = false         }     } } public client_connect(id) {         new i         for( i = 1; i < get_maxplayers(); i++) {                 PickPocketed[id][i] = false     } }
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-22-2005 , 22:30  
Reply With Quote #4

Are you sure there are no load errors?
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 10-22-2005 , 22:48  
Reply With Quote #5

This is the only error i keep getting

Code:
L 10/22/2005 - 21:44:03: [PickPocket.amxx] Reseting PickPocketing Bool
L 10/22/2005 - 21:44:03: [AMXX] Displaying debug trace (plugin "PickPocket.amxx")
L 10/22/2005 - 21:44:03: [AMXX] Run time error 4: index out of bounds (array "PickPocketed[33][33]") (unknown index "33")
L 10/22/2005 - 21:44:03: [AMXX]    [0] PickPocket.sma::Round_Start (line
I have maked line 213:

Code:
#include <amxmodx> #include <cstrike> new bool:PickPocketed[33][33] /* This array is used to check who pick pockted who. For example: If i am in slot 1 and pick pocet someone in slot 2 I would to PickPocketed[1][2] = true to prevent them from pickpocketing over and over again. */ public plugin_init() {     register_plugin( "PickPocket", "1.0", "Zenith77" )         register_clcmd( "amx_pickpocket", "pickpocket", ADMIN_ALL, "Pickpockets the person near you!" )         register_cvar( "pp_ppradius", "10" )     register_cvar( "pp_pickamount", "1000" )     register_cvar( "sv_pickpocket", "1" )         register_logevent("Round_Start", 2, "0=World triggered", "1=Round_Start")       } public pickpocket(id) {         if( !get_cvar_num("sv_pickpocket") ) {                 client_print(id, print_chat, "[AMXX] Sorry, pick pocketing is disabled ! " )                 return PLUGIN_HANDLED     }         new pocketer_origin[3]     new victim_origin[3]     new pp_radius           pp_radius = get_cvar_num("pp_ppradius")         get_user_origin(id, pocketer_origin)             for( new i = 1; i<get_maxplayers(); i++) {                 if( !is_user_connected(i) ) continue                         if( is_user_alive(id) && is_user_alive(i) && get_user_team(id) != get_user_team(i) ) { // prevents pick pocketing from you own team.. etc                         if( i == id ) return PLUGIN_CONTINUE                         get_user_origin(i, victim_origin)                         new distance = get_distance( pocketer_origin, victim_origin )                         if( distance <= pp_radius ) {                                 if( PickPocketed[id][i] ) {                                         client_print(id, print_chat, "[AMXX] You have already pick pocketed your target! " )                                         return PLUGIN_HANDLED                                     }                                 cs_get_user_money(id)                 cs_get_user_money(i)                 // the above is just so it can "refernce" it                                 //[][][][][][][][][][][][][][][][][][][]                 // the below checks if the victim has no money or if                 // the pick pocketer has 16000 dollars..if so action is cancled!                 if(cs_get_user_money(i) == 0) {                     client_print(id, print_chat, "[AMXX] Your Target has no money for you to take! Go search for someone else!" )                     return PLUGIN_HANDLED                 }                 if(cs_get_user_money(id) == 16000){                     client_print(id, print_chat, "[AMXX] Ok now your just being greedy, you already have the max amount of money [ $16000  ]" )                     return PLUGIN_HANDLED                 }                 //[][][][][][][][][][][][][][][][][][][][]                                                 new amount = get_cvar_num("pp_pickamount")                 new result                 new p_amount // pick pocketer amount of money                 new v_amount // victim amount of money                                 p_amount = cs_get_user_money(id)                 v_amount = cs_get_user_money(i)                                 if(get_cvar_num("pp_pickamount") > v_amount) {                                         new result2                                         // If you will noitce below this one is "equation" is different from the                     // one in the code below...this prevents negative numbers and                     // makes sure that if the vitim has less money than the pp_pickamount cvar                     //it prevents the pickpocketer from getting all the money....                                         result2 = amount - v_amount                                         new amount_pp                     amount_pp = p_amount + result2                                         cs_set_user_money(i, 0, 1)                     cs_set_user_money(id, amount_pp, 1)                                         client_print(i, print_chat, "[AMXX] OH NO! You've been pick pocketed!")                     client_print(id, print_chat, "[AMXX] Congrats on your successful Pick! You never cease to amaze me ;)" )                                         PickPocketed[id][i] = true                                         return PLUGIN_HANDLED                 }                                 if(get_cvar_num("pp_pickamount") < v_amount) {                     // once again...do not modify the below....                                         result = v_amount - amount                                         new amount_pp = p_amount + result                                         cs_set_user_money(i, result, 1)                     cs_set_user_money(id, amount_pp, 1)                                         client_print(i, print_chat, "[AMXX] OH NO! You've been pick pocketed!")                     client_print(id, print_chat, "[AMXX] Congrats on your successful Pick! You never cease to amaze me ;)" )                                         PickPocketed[id][i] = true                                         return PLUGIN_HANDLED                 }             }         }     }     return PLUGIN_HANDLED } public Round_Start() {         /*     Globaly Resets the PickPocketed bool.     */         /*     Debugging:     */         log_amx("Reseting PickPocketing Bool")         new i         for( i = 1; i < get_maxplayers(); i++ ) {                 if( !is_user_connected(i) ) continue                 new i2                 for( i2 = 1; i2 <get_maxplayers(); i++ ) {     // LINE 213 ***********************             PickPocketed[i][i2] = false         // LINE 213 ***********************         }     } } public client_connect(id) {         new i         for( i = 1; i < get_maxplayers(); i++) {                 PickPocketed[id][i] = false     } }
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-23-2005 , 00:50  
Reply With Quote #6

Code:
    for( i = 1; i < get_maxplayers(); i++ ) {                 if( !is_user_connected(i) ) continue                 new i2                 for( i2 = 1; i2 <get_maxplayers(); i++ ) {     // LINE 213 ***********************                 PickPocketed[i][i2] = false         // LINE 213 ***********************         }     }

The second for loop increments i every iteration instead of i2. Also, it should be <= get_maxplayers()
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 10-23-2005 , 00:52  
Reply With Quote #7

I dont follow?


Code snippet plz :-)
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-23-2005 , 00:57  
Reply With Quote #8

For loops work like this:

Code:
for(initation code; loop condition; iteration code) {    statements }

The initation code is executed once when the loop beings. It is generally used to setup a variable to be used in the loop (ie: new i = 1).

The loop continues to execute the statements over and over again until the loop condition is met. This is usually a simple number counter (ie: i <= get_maxplayers()).

At the end of every iteration, the iteration code is run. Once again, this is generally used to increment the variable you are using to count (ie: i++).



Compare your first for loop with your second for loop, just the very beginning line that defines the loop. You will see the problem eventually.

Code:
for( i = 1; i < get_maxplayers(); i++ )  for( i2 = 1; i2 <get_maxplayers(); i++ )
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 10-23-2005 , 01:06  
Reply With Quote #9

I still dont get it.

I was trying to reset the entire mutli deminsional array.


My plan:

IN order to do this, i had to loop through the first dimension

then i would execute another loop to loop the second dimension, reseting everything for that slot, and so on.


I still dont get whats wrong with it


*EDIT** HOLY CRAP

Noob mistake, Dude lol i am sooo sry, its like 12:00 am here ^^.. i need to go to bed
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
atomic
Veteran Member
Join Date: Jan 2005
Location: What The Foot?
Old 10-23-2005 , 07:41  
Reply With Quote #10

maybe you need to add some modules?... i dunno
__________________
atomic is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:01.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode