Raised This Month: $ Target: $400
 0% 

[ Request ] nvault & add / remove a plr


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 06-25-2012 , 04:27   [ Request ] nvault & add / remove a plr
Reply With Quote #1

Hello ,
My code :
Code:
#include < amxmodx > #include < amxmisc > #include < nvault > #define CMDTARGET_NO_BOTS  (1<<3) new g_iSaving; new bool: g_bIsVip[ 33 ]; public plugin_init( ) {     register_plugin( "Vip test" , "1.0" , "Aooka" );     register_concmd( "amx_addvip" , "CmdAddVip" , ADMIN_IMMUNITY , "<#userid>" );     register_concmd( "amx_removevip" , "CmdRemoveVip" , ADMIN_IMMUNITY , "<#userid>" );     register_clcmd( "say /vip" , "VipMenu" );     g_iSaving = nvault_open( "vip_file" );     new iMenu = menu_create( "Awesome Vip Menu" , "Handler_Menu" );     menu_additem( iMenu , "Test 1" , "1" , 0 );     menu_additem( iMenu , "Test 2" , "2" , 0 );     menu_setprop( iMenu , MPROP_EXITNAME , "Sortir" ); } public client_putinserver( id ) {     g_bIsVip[ id ] = false; } public plugin_end( ) {     nvault_close( g_iSaving ); } public VipMenu( id , iMenu ) {     if( is_user_alive( id ) && g_bIsVip[ id ] == true )     {         menu_display( id , iMenu , 0 );     }     else     {         client_print( id , print_center , "If you whant to go to the VipMenu you msut be a Vip" );     } } public Handler_Menu( id , iMenu , item ) {     if( item != MENU_EXIT )     {         switch( item )         {             case 1:                 client_print( id , print_center , "Test 1 :: OK" );             case 2:                 client_print( id , print_center , "Test 2 :: OK" );         }     }     else     {         client_print( id , print_center , "Menu is closed" );         menu_destroy( iMenu );     } } public CmdAddVip( id , level , cid ) {     if( !cmd_access( id , level , cid , 2 ) )     {         return 1;     }     else     {         new szArg[ 36 ];         read_argv( 1 , szArg , charsmax( szArg ) );         new target = cmd_target( id , szArg , CMDTARGET_NO_BOTS );         if( !target )         {             console_print( id , "Player not found" );             return 1;         }                 else if( g_bIsVip[ target ] == true )         {             console_print( id , "Player is alrady a Vip" );             return 1;         }                 static szName[ 2 ][ 36 ];         get_user_name( id , szName[ 0 ] , charsmax( szName[ ] ) );         get_user_name( target , szName[ 1 ] , charsmax( szName[ ] ) );         static szAuthID[ 2 ][ 35 ];         get_user_authid( id , szAuthID[ 0 ] , charsmax( szAuthID[ ] ) );         get_user_authid( target , szAuthID[ 1 ] , charsmax( szAuthID[ ] ) );             client_print( 0 , print_chat , "%s (%s) gave a Vip place for the player %s (%s)" , szName[ 0 ] , szAuthID[ 0 ] , szName[ 1 ] , szAuthID[ 1 ] );             log_amx( "%s (%s) gave a place of Vip to %s (%s)" , szName[ 0 ] , szAuthID[ 0 ] , szName[ 1 ] , szAuthID[ 1 ] ); } public CmdRemoveVip( id , level , cid ) {     if( !cmd_access( id , level , cid , 2 ) )     {         return 1;     }         new szArg[ 36 ];     read_argv( 1 , szArg , charsmax( szArg ) );         new target = cmd_target( id , szArg , CMDTARGET_NO_BOTS );         if( !target )     {         console_print( id , "Player not found" );         return 1;     }         else if( g_bIsVip[ target ] == false )     {         g_bIsVip[ target ] = true;     }         static szName[ 2 ][ 36 ];     get_user_name( id , szName[ 0 ] , charsmax( szName[ ] ) );     get_user_name( target , szName[ 1 ] , charsmax( szName[ ] ) );     static szAuthID[ 2 ][ 35 ];     get_user_authid( id , szAuthID[ 0 ] , charsmax( szAuthID[ ] ) );     get_user_authid( target , szAuthID[ 1 ] , charsmax( szAuthID[ ] ) );         client_print( 0 , print_chat , "%s (%s) remove a Vip place for the player %s (%s)" , szName[ 0 ] , szAuthID[ 0 ] , szName[ 1 ] , szAuthID[ 1 ] );         log_amx( "%s (%s) remove a place of Vip to %s (%s)" , szName[ 0 ] , szAuthID[ 0 ] , szName[ 1 ] , szAuthID[ 1 ] ); }

It do not work and i test a lots of things this last weeks but ...

So thank you in advance all
__________________
Pawn ? Useless
Aooka is offline
Sherazaa
Member
Join Date: Jun 2012
Old 06-25-2012 , 08:07   Re: [ Request ] nvault & add / remove a plr
Reply With Quote #2

What is this !!
szName[ 2 ][ 36 ];

Why they are 2 arrays O_O
__________________
[B]Bhop & Kz Player
Sherazaa is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-25-2012 , 08:16   Re: [ Request ] nvault & add / remove a plr
Reply With Quote #3

Quote:
Originally Posted by Sherazaa View Post
What is this !!
szName[ 2 ][ 36 ];

Why they are 2 arrays O_O
For 2 different players.


Aooka, you never set the VIP bool to true in the CmdAddVip() function. You included nVault which you have open and closed a vault file, but never done anything with it? Also, there is no need to define CMDTARGET_NO_BOTS because it is an already defined constant in amxmisc. And for the understanding of how your defining your variables, it is unnecessary for you to use static in these cases, use new instead. You only need to use static when creating large arrays ( for example an MOTD ) or when your calling the function with an array / string very often.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 06-25-2012 at 08:18.
hornet is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-25-2012 , 12:10   Re: [ Request ] nvault & add / remove a plr
Reply With Quote #4

Quote:
Originally Posted by Sherazaa View Post
What is this !!
szName[ 2 ][ 36 ];

Why they are 2 arrays O_O
It's a 2-dimensional array.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Sherazaa
Member
Join Date: Jun 2012
Old 06-25-2012 , 12:37   Re: [ Request ] nvault & add / remove a plr
Reply With Quote #5

Okay thanks I go look a tutoriel about it !
__________________
[B]Bhop & Kz Player
Sherazaa is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 06-25-2012 , 12:58   Re: [ Request ] nvault & add / remove a plr
Reply With Quote #6

@Sherazaa: Take just a look here : http://wiki.amxmodx.org/Pawn_Tutoria...nsional_Arrays

@Hornet: So i do that :
Code:
#include < amxmodx > #include < amxmisc > #include < nvault > new g_iSaving; new bool: g_bIsVip[ 33 ]; public plugin_init( ) {     register_plugin( "Vip test" , "1.0" , "Aooka" );     register_concmd( "amx_addvip" , "CmdAddVip" , ADMIN_IMMUNITY , "<#userid>" );     register_concmd( "amx_removevip" , "CmdRemoveVip" , ADMIN_IMMUNITY , "<#userid>" );         register_clcmd( "say /vip" , "VipMenu" );         g_iSaving = nvault_open( "vip_file" );         new const iMenu = menu_create( "Awesome Vip Menu" , "Handler_Menu" );     menu_additem( iMenu , "Test 1" , "1" , 0 );     menu_additem( iMenu , "Test 2" , "2" , 0 );         menu_setprop( iMenu , MPROP_EXITNAME , "Sortir" ); } public client_putinserver( id ) {     g_bIsVip[ id ] = false; } public plugin_end( ) {     nvault_close( g_iSaving ); } public VipMenu( id , iMenu ) {     if( is_user_alive( id ) && g_bIsVip[ id ] == true )     {         menu_display( id , iMenu , 0 );     }     else     {         client_print( id , print_center , "If you whant to go to the VipMenu you msut be a Vip" );     }   } public Handler_Menu( id , iMenu , item ) {     if( item != MENU_EXIT )     {         switch( item )         {             case 1:                 client_print( id , print_center , "Test 1 :: OK" );             case 2:                 client_print( id , print_center , "Test 2 :: OK" );         }     }     else     {         client_print( id , print_center , "Menu is closed" );         menu_destroy( iMenu );     } } public CmdAddVip( id , level , cid ) {     if( !cmd_access( id , level , cid , 2 ) )     {         return 1;     }     else     {         new szArg[ 36 ];         read_argv( 1 , szArg , charsmax( szArg ) );         new target = cmd_target( id , szArg , CMDTARGET_NO_BOTS );         if( !target )         {             console_print( id , "Player not found" );             return 1;         }                 else if( g_bIsVip[ target ] == true )         {             console_print( id , "Player is alrady a Vip" );             return 1;         }         else         {             g_bIsVip[ target ] = true;                         new szName[ 2 ][ 36 ];             get_user_name( id , szName[ 0 ] , charsmax( szName[ ] ) );             get_user_name( target , szName[ 1 ] , charsmax( szName[ ] ) );                         new szAuthID[ 2 ][ 35 ];             get_user_authid( id , szAuthID[ 0 ] , charsmax( szAuthID[ ] ) );             get_user_authid( target , szAuthID[ 1 ] , charsmax( szAuthID[ ] ) );                         client_print( 0 , print_chat , "%s (%s) gave a Vip place for the player %s (%s)" , szName[ 0 ] , szAuthID[ 0 ] , szName[ 1 ] , szAuthID[ 1 ] );                         log_amx( "%s (%s) gave a place of Vip to %s (%s)" , szName[ 0 ] , szAuthID[ 0 ] , szName[ 1 ] , szAuthID[ 1 ] );         }     }     return 0; } public CmdRemoveVip( id , level , cid ) {     if( !cmd_access( id , level , cid , 2 ) )     {         return 1;     }             new szArg[ 36 ];     read_argv( 1 , szArg , charsmax( szArg ) );             new target = cmd_target( id , szArg , CMDTARGET_NO_BOTS );             if( !target )     {         console_print( id , "Player not found" );         return 1;     }             else if( g_bIsVip[ target ] == false )     {         console_print( id , "Player is not a Vip" );         return 1;     }     else     {         new szName[ 2 ][ 36 ];         get_user_name( id , szName[ 0 ] , charsmax( szName[ ] ) );         get_user_name( target , szName[ 1 ] , charsmax( szName[ ] ) );                 new szAuthID[ 2 ][ 35 ];         get_user_authid( id , szAuthID[ 0 ] , charsmax( szAuthID[ ] ) );         get_user_authid( target , szAuthID[ 1 ] , charsmax( szAuthID[ ] ) );                 client_print( 0 , print_chat , "%s (%s) remove a Vip place for the player %s (%s)" , szName[ 0 ] , szAuthID[ 0 ] , szName[ 1 ] , szAuthID[ 1 ] );                     log_amx( "%s (%s) remove a place of Vip to %s (%s)" , szName[ 0 ] , szAuthID[ 0 ] , szName[ 1 ] , szAuthID[ 1 ] );     }     return 0; }

It do not work.
I've a problem and i know what is it but i don't know how to do.
It's for the nVault system.
Yes I open & close it and ... nothing :/

I don't know what can i use in this list : http://www.amxmodx.org/funcwiki.php?go=inc&id=41
If it is in this list...

Thank you in advance
__________________
Pawn ? Useless
Aooka is offline
Sherazaa
Member
Join Date: Jun 2012
Old 06-25-2012 , 13:00   Re: [ Request ] nvault & add / remove a plr
Reply With Quote #7

Quote:
Originally Posted by Aooka View Post
@Sherazaa: Take just a look here : http://wiki.amxmodx.org/Pawn_Tutoria...nsional_Arrays
Ok, thanks
__________________
[B]Bhop & Kz Player
Sherazaa is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-25-2012 , 13:46   Re: [ Request ] nvault & add / remove a plr
Reply With Quote #8

1. You added a variable "iMenu" to your command callback. That does not exist. You cannot just add variables to a public function callback and expect it to work.
By that logic, I could do:
Code:
public VipMenu( id, Float:health, weapons[], attacker, all_players[] )
But no, you cannot do that.

2. Make the menu global so it can be accessed. Otherwise the handle is unused.

3. Don't destroy the menu, ever. It is created once and never again, so if you close it once, it is destroyed, and then you cannot access it anymore.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 06-25-2012 at 13:47.
Exolent[jNr] is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 06-25-2012 , 14:44   Re: [ Request ] nvault & add / remove a plr
Reply With Quote #9

Quote:
Originally Posted by Exolent[jNr] View Post
But no, you cannot do that.
So what can i do for that ?
I test tomorrow thanks
__________________
Pawn ? Useless
Aooka is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-25-2012 , 15:41   Re: [ Request ] nvault & add / remove a plr
Reply With Quote #10

Quote:
Originally Posted by Aooka View Post
So what can i do for that ?
I test tomorrow thanks
Quote:
Originally Posted by Exolent[jNr] View Post
2. Make the menu global
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply


Thread Tools
Display Modes

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 06:15.


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