AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [REQ] nVault & Vip - Function problem (https://forums.alliedmods.net/showthread.php?t=187730)

Aooka 06-17-2012 05:56

[REQ] nVault & Vip - Function problem
 
So it's me again :crab:

I'm already starting by giving you my code :
Code:
#include < amxmodx > #include < nvault > new g_iSaving; new bool: g_bIsVip[ 33 ]; public plugin_init( ) {     register_plugin( "Vip original" , "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 ) {     new target;         static szName[ 2 ][ 36 ];     get_user_name( id , szName[ 0 ] , charsmax( szName ) );     get_user_name( target , szName[ 1 ] , charsmax( szName ) );         client_print( 0 , print_chat , "%s gave a Vip place for the player %s" , szName[ 0 ] , szName[ 1 ] ); }

I do this about two days ago and today. But (yes but !! ^^ ) i've a big problem with the last function ( public CmdAddVip( id ) )
I do not know the process well :S and Where to start ...

Ps: I've watched how other plugins functioned... :3

If someone could help me do this function and explaining to me his approach it would be very useful for me :bacon!:


Thank you in advance rukia

hornet 06-17-2012 07:12

Re: [REQ] nVault & Vip - Function problem
 
So what is the purpose of using nVault? If its to save VIPs then just write to an INI file.

Aooka 06-17-2012 08:07

Re: [REQ] nVault & Vip - Function problem
 
Hum ... No i just want a code wich does when an admin type amx_addvip "nickname" in the console they are a new vip.

Just that, not a .ini file for the moment ^^

I see this method by Exolent[jNr] :
Code:
public CmdGiveXP(client, level, cid) {     if( !cmd_access(client, level, cid, 3) ) return PLUGIN_HANDLED;         static arg[35];     read_argv(1, arg, sizeof(arg) - 1);         new target = cmd_target(client, arg, CMDTARGET_OBEY_IMMUNITY|CMDTARGET_NO_BOTS);     if( !target ) return PLUGIN_HANDLED;         if( !IsUserAuthorized(target) )     {         console_print(client, "Target has not authorized with the server.");         return PLUGIN_HANDLED;     }         read_argv(2, arg, sizeof(arg) - 1);     new xp = str_to_num(arg);         if( xp <= 0 )     {         console_print(client, "XP must be a value greater than 0!");         if( xp < 0 )         {             console_print(client, "Use hnsxp_remove_xp instead.");         }         return PLUGIN_HANDLED;     }         g_xp[target] += xp;         Save(target);         static name[2][32];     get_user_name(client, name[0], sizeof(name[]) - 1);     get_user_name(target, name[1], sizeof(name[]) - 1);         Print(0, "%s gave %i XP to %s.", name[0], xp, name[1]);         static steamid[2][35];     get_user_authid(client, steamid[0], sizeof(steamid[]) - 1);     get_user_authid(target, steamid[1], sizeof(steamid[]) - 1);         log_amx("%s (%s) gave %i XP to %s (%s)", name[0], steamid[0], xp, name[1], steamid[1]);         return PLUGIN_HANDLED; }

And i would like to do the same but i don't understand all ...
Like for example : level and cid etc...

hornet 06-17-2012 08:23

Re: [REQ] nVault & Vip - Function problem
 
nVault is used to save data via a key and a data string or integer.

So players will only be VIP of the map:
Code:
public CmdAddVip( id, level, cid ) {     if( !cmd_access( id, level, cid, 2 ) )         return PLUGIN_HANDLED;         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 PLUGIN_HANDLED;     }         static szName[ 2 ][ 36 ];     get_user_name( id , szName[ 0 ] , charsmax( szName[] ) );     get_user_name( target , szName[ 1 ] , charsmax( szName[] ) );         client_print( 0 , print_chat , "%s gave a Vip place for the player %s" , szName[ 0 ] , szName[ 1 ] );         return PLUGIN_HANDLED; }
As for info on the function:
http://www.amxmodx.org/funcwiki.php?...cess&go=search

Aooka 06-17-2012 10:09

Re: [REQ] nVault & Vip - Function problem
 
Oh Thanks a lot !
But is it possible to add a Vip on all maps with no .ini file ?

And can you comment this part of plugin for me please :
Code:
if( !cmd_access( id, level, cid, 2 ) )
What is level and cid please ?

I reade it : http://www.amxmodx.org/funcwiki.php?go=func&id=175 but I really do not understand that :3

So ...

Thanks :D

Aooka 06-18-2012 06:29

Re: [REQ] nVault & Vip - Function problem
 
And i forget that part :
Code:
new szArg[ 36 ]; read_argv( 1, szArg, charsmax( szArg ) );

If you can just help me ^^

Thank you in advance

<VeCo> 06-19-2012 15:59

Re: [REQ] nVault & Vip - Function problem
 
read_argv() gets an argument from a command. In that case it gets the first argument of the amx_addvip command (which is the #userid) and stores it in the szArg string variable.

Aooka 06-20-2012 06:44

Re: [REQ] nVault & Vip - Function problem
 
if( !cmd_access( id, level, cid, 2 ) )

Just why do you choose num 2 at the end of the stock ? And not 1 ? Because where are the two argument (lol)...
I don't see it.

And please what is cid ? (and level)

<VeCo> 06-20-2012 08:10

Re: [REQ] nVault & Vip - Function problem
 
2 means the number of command arguments that should be passed to the function in order to work. The command itself is also counted, so that's why it's 2. Now, if you write the command without setting "#userid" argument, it will print a message about the command usage (the message text is that from the 4th parameter of register_clcmd) and the function won't be executed.

About level and cid - they are allways like that, you won't need to change them. Level is the access level from the 2nd parameter of register_clcmd, cid shouldn't be touched - it's about the console message if you don't have the needed access or you have passed wrong number of command arguments.


All times are GMT -4. The time now is 06:13.

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