AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Integer not working (https://forums.alliedmods.net/showthread.php?t=127004)

OneMoreLevel 05-16-2010 00:13

Integer not working
 
I've got this code, and my main goal besides providing a list of shop items, is to make it so that you can only purchase 3 items per life. However, it is three items per map. The integer at the bottom of the code is not resetting, any help?

Also, if my code can be optimized, i would appreciate it.

PHP Code:

#include < amxmodx > 
#include < cstrike > 
#include < hamsandwich > 

#define MAX_MONEY 16000 

#define CT_MONEY_PER_SECOND 2 

#define T_MONEY_PER_CT_KILL 250 

public plugin_init( ) 

    
register_plugin"Money Maker""0.0.1""Exolent" ); 
     
    
RegisterHamHam_Spawn"player""FwdPlayerSpawnPost"); 
    
RegisterHamHam_Killed"player""FwdPlayerKilledPost"); 


public 
client_disconnectiPlayer 

    
remove_taskiPlayer ); 


public 
FwdPlayerSpawnPostiPlayer 

    if( 
is_user_aliveiPlayer ) ) 
    { 
        if( 
cs_get_user_teamiPlayer ) == CS_TEAM_CT 
        { 
            if( !
task_existsiPlayer ) ) 
            { 
                
set_task1.0"TaskGiveMoney"iPlayer ); 
            } 
        } 
        else 
        { 
            
remove_taskiPlayer ); 
        } 
    } 


public 
FwdPlayerKilledPostiVictimiKillerbShouldGib 

    if( 
cs_get_user_teamiVictim ) == CS_TEAM_CT 
    
&&  is_user_connectediKiller 
    &&  
cs_get_user_teamiKiller ) == CS_TEAM_T 
    { 
        new 
iPlayers32 ], iNum
        
get_playersiPlayersiNum"h" ); 
         
        for( new 
0iNumi++ ) 
        { 
            
iVictim iPlayers]; // no need for a new variable 
             
            
if( iVictim == iKiller 
            
||  cs_get_user_teamiVictim ) == CS_TEAM_T 
            { 
                
GiveMoneyiVictimT_MONEY_PER_CT_KILL ); 
            } 
        } 
    } 


public 
TaskGiveMoneyiPlayer 

    if( 
is_user_aliveiPlayer 
    &&  
cs_get_user_teamiPlayer ) == CS_TEAM_CT 
    { 
        
GiveMoneyiPlayerCT_MONEY_PER_SECOND ); 
         
        
set_task1.0"TaskGiveMoney"iPlayer ); 
    } 


GiveMoneyiPlayeriMoneyToGive 

    new 
iMoney cs_get_user_moneyiPlayer ); 
     
    if( 
iMoney MAX_MONEY 
    { 
        
iMoney min( ( iMoney iMoneyToGive ), MAX_MONEY ); 
         
        
cs_set_user_moneyiPlayeriMoney ); 
    } 



fysiks 05-16-2010 01:19

Re: Integer not working
 
Quote:

Originally Posted by OneMoreLevel (Post 1181662)
I've got this code, and my main goal besides providing a list of shop items, is to make it so that you can only purchase 3 items per life. However, it is three items per map. The integer at the bottom of the code is not resetting, any help?

Also, if my code can be optimized, i would appreciate it.

PHP Code:

#include < amxmodx > 
#include < cstrike > 
#include < hamsandwich > 

#define MAX_MONEY 16000 

#define CT_MONEY_PER_SECOND 2 

#define T_MONEY_PER_CT_KILL 250 

public plugin_init( ) 

    
register_plugin"Money Maker""0.0.1""Exolent" ); 
     
    
RegisterHamHam_Spawn"player""FwdPlayerSpawnPost"); 
    
RegisterHamHam_Killed"player""FwdPlayerKilledPost"); 


public 
client_disconnectiPlayer 

    
remove_taskiPlayer ); 


public 
FwdPlayerSpawnPostiPlayer 

    if( 
is_user_aliveiPlayer ) ) 
    { 
        if( 
cs_get_user_teamiPlayer ) == CS_TEAM_CT 
        { 
            if( !
task_existsiPlayer ) ) 
            { 
                
set_task1.0"TaskGiveMoney"iPlayer ); 
            } 
        } 
        else 
        { 
            
remove_taskiPlayer ); 
        } 
    } 


public 
FwdPlayerKilledPostiVictimiKillerbShouldGib 

    if( 
cs_get_user_teamiVictim ) == CS_TEAM_CT 
    
&&  is_user_connectediKiller 
    &&  
cs_get_user_teamiKiller ) == CS_TEAM_T 
    { 
        new 
iPlayers32 ], iNum
        
get_playersiPlayersiNum"h" ); 
         
        for( new 
0iNumi++ ) 
        { 
            
iVictim iPlayers]; // no need for a new variable 
             
            
if( iVictim == iKiller 
            
||  cs_get_user_teamiVictim ) == CS_TEAM_T 
            { 
                
GiveMoneyiVictimT_MONEY_PER_CT_KILL ); 
            } 
        } 
    } 


public 
TaskGiveMoneyiPlayer 

    if( 
is_user_aliveiPlayer 
    &&  
cs_get_user_teamiPlayer ) == CS_TEAM_CT 
    { 
        
GiveMoneyiPlayerCT_MONEY_PER_SECOND ); 
         
        
set_task1.0"TaskGiveMoney"iPlayer ); 
    } 


GiveMoneyiPlayeriMoneyToGive 

    new 
iMoney cs_get_user_moneyiPlayer ); 
     
    if( 
iMoney MAX_MONEY 
    { 
        
iMoney min( ( iMoney iMoneyToGive ), MAX_MONEY ); 
         
        
cs_set_user_moneyiPlayeriMoney ); 
    } 





I think you need to learn how to copy and paste. That code has nothing to do with your post.

lazarev 05-16-2010 01:25

Re: Integer not working
 
reset buy counter at round end/start, or at spawn :)


All times are GMT -4. The time now is 03:43.

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