|
Author
|
Message
|
|
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
|

05-16-2010
, 01:19
Re: Integer not working
|
#1
|
Quote:
Originally Posted by OneMoreLevel
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" );
RegisterHam( Ham_Spawn, "player", "FwdPlayerSpawnPost", 1 );
RegisterHam( Ham_Killed, "player", "FwdPlayerKilledPost", 1 );
}
public client_disconnect( iPlayer )
{
remove_task( iPlayer );
}
public FwdPlayerSpawnPost( iPlayer )
{
if( is_user_alive( iPlayer ) )
{
if( cs_get_user_team( iPlayer ) == CS_TEAM_CT )
{
if( !task_exists( iPlayer ) )
{
set_task( 1.0, "TaskGiveMoney", iPlayer );
}
}
else
{
remove_task( iPlayer );
}
}
}
public FwdPlayerKilledPost( iVictim, iKiller, bShouldGib )
{
if( cs_get_user_team( iVictim ) == CS_TEAM_CT
&& is_user_connected( iKiller )
&& cs_get_user_team( iKiller ) == CS_TEAM_T )
{
new iPlayers[ 32 ], iNum;
get_players( iPlayers, iNum, "h" );
for( new i = 0; i < iNum; i++ )
{
iVictim = iPlayers[ i ]; // no need for a new variable
if( iVictim == iKiller
|| cs_get_user_team( iVictim ) == CS_TEAM_T )
{
GiveMoney( iVictim, T_MONEY_PER_CT_KILL );
}
}
}
}
public TaskGiveMoney( iPlayer )
{
if( is_user_alive( iPlayer )
&& cs_get_user_team( iPlayer ) == CS_TEAM_CT )
{
GiveMoney( iPlayer, CT_MONEY_PER_SECOND );
set_task( 1.0, "TaskGiveMoney", iPlayer );
}
}
GiveMoney( iPlayer, iMoneyToGive )
{
new iMoney = cs_get_user_money( iPlayer );
if( iMoney < MAX_MONEY )
{
iMoney = min( ( iMoney + iMoneyToGive ), MAX_MONEY );
cs_set_user_money( iPlayer, iMoney );
}
}
|
I think you need to learn how to copy and paste. That code has nothing to do with your post.
__________________
|
|
|
|