AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Give XP Question (https://forums.alliedmods.net/showthread.php?t=171861)

Napoleon_be 11-11-2011 19:27

[HELP] Give XP Question
 
Sup folks,

I'm creating a XP Mode and i would like to add a pcvar wich adds XP to my current XP. I would like to ask how to make the pcvar like and wich function i have to use, once i know how to add the pcvar and wich function i should use, it's easy

PHP Code:

iPlayerXP[id] += get_pcvar_num(NUM HERE


Devil259 11-11-2011 19:46

Re: [HELP] Give XP Question
 
Code:
new g_pCvarAddXP public plugin_init( ) {      g_pCvarAddXP = register_cvar( "amx_addxp" , "100" ) // value } /* Use iPlayerXP[ index ] += get_pcvar_num( g_pCvarAddXP ) */

Napoleon_be 11-11-2011 20:55

Re: [HELP] Give XP Question
 
k thanks, but wich public function?

Chaato 11-12-2011 02:04

Re: [HELP] Give XP Question
 
other forms
PHP Code:



/*---------------------With "define"----------------------*/

#define EXP 100

public plugin_init()
{
    
register_pluginPluginNamePluginVersionPluginAutor )
    
    
}

iPlayerindex ] += EXP

/*-------------------------------------------------------------------*/

/*---------------------With "variable"----------------------*/


new gCvarExp;

public 
plugin_init()
{
    
register_pluginPluginNamePluginVersionPluginAutor )
    
    
gCvarExp register_cvar"amx_winexp""100" )
}

iPlayerindex ] += get_pcvar_numgCvarExp )


/*-------------------------------------------------------------------*/
/*---------------------With "number"----------------------*/

public plugin_init()
{
    
register_pluginPluginNamePluginVersionPluginAutor )
    
    
gCvarExp register_cvar"amx_winexp""100" )
}

iPlayerindex ] += 100

/*-------------------------------------------------------------------*/ 


Erox902 11-12-2011 07:45

Re: [HELP] Give XP Question
 
Quote:

Originally Posted by Napoleon_be (Post 1594949)
k thanks, but wich public function?

That is up to you not us. We have not even seen your code, were not psychic you know :/
And you don't really need to make a function to add it, just give it like the examples show at the specific event you want to give someone it.

Napoleon_be 11-12-2011 11:09

Re: [HELP] Give XP Question
 
Okay, thanks everyone.

I've done it like this just with a concmd:
PHP Code:

public XPGive(iPlayerlevelcid) {
    if(!
cmd_access(iPlayerlevelcid3)) {
        return 
PLUGIN_HANDLED
    
}
    static 
arg[35]
    
read_argv(1argcharsmax(arg))
    
    new 
target cmd_target(iPlayerargCMDTARGET_NO_BOTS)
    if(!
target) {
        return 
PLUGIN_HANDLED
    
}
    
    
read_argv(2argcharsmax(arg))
    new 
XP str_to_num(arg)
    
    if(
XP <= 0) {
        
console_print(iPlayer"You need to add more XP Points!")
        if(
XP 0) {
            
console_print(iPlayer"Value must be greater than 0, else user xp_removexp")
        }
        return 
PLUGIN_HANDLED
    
}
    if(
XP 9999999) {
        
console_print(iPlayer"Value is too big to add!")
    }
    
    
iPlayerXP[target] += XP
    
    
static szName[2][32];
    
get_user_name(iPlayerszName[0], charsmax(szName[]))
    
get_user_name(targetszName[1], charsmax(szName[]))
    
    
ColorChat(0GREEN"%s^x03 %s^x01 gave^x03 %s^x04 %i^x01 XP Points!"iPrefixszName[0], szName[1], XP)
    
    static 
iSteamid[2][35]
    
get_user_authid(iPlayeriSteamid[0], charsmax(iSteamid[]))
    
get_user_authid(targetiSteamid[1], charsmax(iSteamid[]))
    
    return 
PLUGIN_HANDLED




All times are GMT -4. The time now is 14:27.

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