Raised This Month: $ Target: $400
 0% 

[Help] Donate frags


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wEEk
Senior Member
Join Date: Sep 2012
Old 04-30-2013 , 18:29   [Help] Donate frags
Reply With Quote #1

Hi, someone could help me tell me how you can do so that you see to donate money, donate frags? The maximum you can donate is 10 frags that alone. My frag variabe is
PHP Code:
 new PlayerXP [33
Code:

PHP Code:
#include <amxmodx> 
#include <hamsandwich> 
#include <cstrike> 

#define PLUGIN "Donar" 
#define VERSION "1.3" 
#define AUTHOR "Stereo" 

const MAX_PLAYERS 32 

new gidPlayer[33
new 
g_msgSayText 

public plugin_init() { 
    
register_plugin(PLUGINVERSIONAUTHOR
    
    
register_clcmd("say /donar""GiveMoneyMenu"
    
register_clcmd("say .donar""GiveMoneyMenu"
    
register_clcmd("say !donar""GiveMoneyMenu"
    
register_clcmd("say donar""GiveMoneyMenu"
    
register_clcmd("Introducir_Dinero""player")
    
    
g_msgSayText get_user_msgid("SayText"



//Menu donar 
public GiveMoneyMenu(id

    static 
opcion[64
    
    
formatex(opcioncharsmax(opcion),"Selecciona a un jugador:"
    new 
iMenu menu_create(opcion"elejir"
    
    new 
players[32], pnumtempid 
    
new name[32], szTempid[10
    
    
get_players(playerspnum"ch"
    
    for( new 
ii<pnumi++ ) 
    { 
        
tempid players[i
        
        if(
cs_get_user_team(tempid) == CS_TEAM_UNASSIGNED && is_user_connected(tempid) || cs_get_user_team(tempid) == CS_TEAM_SPECTATOR && is_user_connected(tempid) || !is_user_connected(tempid) )  
            continue; 
        
        
        
        
get_user_name(tempidname31
        
num_to_str(tempidszTempid9
        
        
formatex(opcioncharsmax(opcion), "\w%s"name
        
menu_additem(iMenuopcionszTempid0
    } 
    
    
menu_display(idiMenu
    return 
PLUGIN_HANDLED 


public 
elejir(idmenuitem

    if( 
item == MENU_EXIT 
    { 
        
menu_destroy(menu
        return 
PLUGIN_HANDLED 
    

    
    new 
Data[6], Name[64
    new 
AccessCallback 
    menu_item_getinfo
(menuitemAccessData,5Name63Callback
    
    new 
tempid str_to_num(Data
    
    
gidPlayer[id] = tempid 
    client_cmd
(id"messagemode Introducir_Dinero"
    
    
menu_destroy(menu
    return 
PLUGIN_HANDLED 


public 
player(id

    new 
say[300
    
read_args(saycharsmax(say)) 
    
    
remove_quotes(say
    
    if(!
is_str_num(say) || equal(say"")) 
        return 
PLUGIN_HANDLED 
    
    frpacks
(idsay)     
    
    return 
PLUGIN_CONTINUE 


frpacks(idsay[]) { 
    new 
amount str_to_num(say
    new 
victim gidPlayer[id
    new 
money cs_get_user_money(id
    
    new 
vname[32], idname[32
    
    if( 
victim && is_user_connected(id) && is_user_connected(victim) ) 
    { 
        
get_user_name(victimvname31
        
get_user_name(ididname31
        
        if(
amount >= money
        { 
            
client_print(idprint_chat"No puedes donar cantidades que no tienes :|"
        } 
        if(
money >= amount
        { 
            
cs_set_user_money(idcs_get_user_money(id) - amount
            
cs_set_user_money(victimcs_get_user_money(victim) + amount
            
ChatColor(0"!g[Furien] !yEl Jugador !g%s !yha donado !g%d !yal jugador !g%s"idnameamountvname
        } 
    } 
    return 
PLUGIN_HANDLED 
}   

stock ChatColor(const id, const input[], any:...) 

    new 
count 1players[32
    static 
msg[191
    
vformat(msg190input3
    
    
replace_all(msg190"!g""^4"
    
replace_all(msg190"!y""^1"
    
replace_all(msg190"!t""^3"
    
    if (
idplayers[0] = id 
    
else get_players(playerscount"ch"
    for (new 
0counti++) 
    { 
        if (
is_user_connected(players[i])) 
        { 
            
message_begin(MSG_ONE_UNRELIABLEg_msgSayText_players[i]) 
            
write_byte(players[i]) 
            
write_string(msg
            
message_end() 
        } 
    } 

And one thing, as you can do for that once done should be deducted from the frags?

Last edited by wEEk; 04-30-2013 at 18:30.
wEEk is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 04-30-2013 , 19:00   Re: [Help] Donate frags
Reply With Quote #2

for max frag donation limit you could make a pcvar..

Code:
new g_pcvarFragLimit; //...... //..... in plugin_init() g_pcvarFragLimit = register_cvar( "amx_frag_limit", "10" ); //.....

then just use the pcvar to when you checking the limit thruout your code.
__________________
Blizzard_87 is offline
wEEk
Senior Member
Join Date: Sep 2012
Old 04-30-2013 , 19:25   Re: [Help] Donate frags
Reply With Quote #3

Ok, now it would be like to donate part?

PHP Code:
#include <amxmodx>  
#include <hamsandwich>  
#include <cstrike>  

#define PLUGIN "Donar"  
#define VERSION "1.3"  
#define AUTHOR "Stereo"  

const MAX_PLAYERS 32  

new gidPlayer[33]  
new 
g_msgSayText  
new PlayerXP[33]
new 
g_pcvarFragLimit;

public 
plugin_init() {  
    
register_plugin(PLUGINVERSIONAUTHOR)  
     
    
register_clcmd("say /donar""GiveMoneyMenu")  
    
register_clcmd("say donar""GiveMoneyMenu")  
    
register_clcmd("Introducir_Dinero""player"
    
    
g_pcvarFragLimit register_cvar"amx_frag_limit""10" );
    
g_msgSayText get_user_msgid("SayText")  
}  


//Menu donar  
public GiveMoneyMenu(id)  
{  
    static 
opcion[64]  
     
    
formatex(opcioncharsmax(opcion),"Selecciona a un jugador:")  
    new 
iMenu menu_create(opcion"elejir")  
     
    new 
players[32], pnumtempid  
    
new name[32], szTempid[10]  
     
    
get_players(playerspnum"ch")  
     
    for( new 
ii<pnumi++ )  
    {  
        
tempid players[i]  
         
        if(
cs_get_user_team(tempid) == CS_TEAM_UNASSIGNED && is_user_connected(tempid) || cs_get_user_team(tempid) == CS_TEAM_SPECTATOR && is_user_connected(tempid) || !is_user_connected(tempid) )   
            continue;  
         
         
         
        
get_user_name(tempidname31)  
        
num_to_str(tempidszTempid9)  
         
        
formatex(opcioncharsmax(opcion), "\w%s"name)  
        
menu_additem(iMenuopcionszTempid0)  
    }  
     
    
menu_display(idiMenu)  
    return 
PLUGIN_HANDLED  
}  

public 
elejir(idmenuitem)  
{  
    if( 
item == MENU_EXIT )  
    {  
        
menu_destroy(menu)  
        return 
PLUGIN_HANDLED  
    
}  
     
    new 
Data[6], Name[64]  
    new 
AccessCallback  
    menu_item_getinfo
(menuitemAccessData,5Name63Callback)  
     
    new 
tempid str_to_num(Data)  
     
    
gidPlayer[id] = tempid  
    client_cmd
(id"messagemode Introducir_Dinero")  
     
    
menu_destroy(menu)  
    return 
PLUGIN_HANDLED  
}  

public 
player(id)  
{  
    new 
say[300]  
    
read_args(saycharsmax(say))  
     
    
remove_quotes(say)  
     
    if(!
is_str_num(say) || equal(say""))  
        return 
PLUGIN_HANDLED  
     
    frpacks
(idsay)      
     
    return 
PLUGIN_CONTINUE  
}  

frpacks(idsay[]) {  
    new 
amount str_to_num(say)  
    new 
victim gidPlayer[id]  
    new 
money cs_get_user_money(id)  
     
    new 
vname[32], idname[32]  
     
    if( 
victim && is_user_connected(id) && is_user_connected(victim) )  
    {  
        
get_user_name(victimvname31)  
        
get_user_name(ididname31)  
         
        if(
amount >= money)  
        {  
            
client_print(idprint_chat"No puedes donar cantidades que no tienes :|")  
        }  
        if(
money >= amount)  
        {  
            
cs_set_user_money(idcs_get_user_money(id) - amount)  
            
cs_set_user_money(victimcs_get_user_money(victim) + amount)  
            
ChatColor(0"!g[Donate] !yEl Jugador !g%s !yha donado !g%d !yal jugador !g%s"idnameamountvname)  
        }  
    }  
    return 
PLUGIN_HANDLED  
}    

stock ChatColor(const id, const input[], any:...)  
{  
    new 
count 1players[32]  
    static 
msg[191]  
    
vformat(msg190input3)  
     
    
replace_all(msg190"!g""^4")  
    
replace_all(msg190"!y""^1")  
    
replace_all(msg190"!t""^3")  
     
    if (
idplayers[0] = id  
    
else get_players(playerscount"ch")  
    for (new 
0counti++)  
    {  
        if (
is_user_connected(players[i]))  
        {  
            
message_begin(MSG_ONE_UNRELIABLEg_msgSayText_players[i])  
            
write_byte(players[i])  
            
write_string(msg)  
            
message_end()  
        }  
    }  

wEEk is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 04-30-2013 , 23:44   Re: [Help] Donate frags
Reply With Quote #4

have a look at the plugin i just released and see how to edit your plugin.

https://forums.alliedmods.net/showthread.php?t=214892
__________________
Blizzard_87 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 10:51.


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