AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Moneyblock Action, help please! (https://forums.alliedmods.net/showthread.php?t=197054)

lukasdaman 09-28-2012 09:47

Moneyblock Action, help please!
 
This is the actioncode I'm using made by Carlen20:

ActionMoney(id, ent)
{
if ( cs_get_user_team(id) == CS_TEAM_T )
{
if ( !g_cash_used[id] )
{
emit_sound(id, CHAN_STATIC, g_sound_money, 1.0, ATTN_NORM, 0, PITCH_NORM);
new property[5];
GetProperty(ent, 1, property);

cm_set_user_cash(id, cm_get_user_cash(id) + str_to_num(property));
cm_cash_used[id] = true;

set_hudmessage(0, 255, 0, 0.01, 0.18, 0, 0.0, 1.0, 0.25, 0.25, 2);
show_hudmessage(id, "You got %i more Money!", str_to_num(property));
}
}

But I get this error when compiling:

/tmp/textDEjy2S.sma(2083) : error 017: undefined symbol "g_cash_used"
/tmp/textDEjy2S.sma(2083) : warning 215: expression has no effect
/tmp/textDEjy2S.sma(2083) : error 001: expected token: ";", but found "]"
/tmp/textDEjy2S.sma(2083) : error 029: invalid expression, assumed zero
/tmp/textDEjy2S.sma(2083) : fatal error 107: too many error messages on one line

Compilation aborted.
4 Errors.

Anyone got the brainpower I don't have to fix it?


If it's of any use I use these natives:

native cm_get_user_cash(client);

native cm_set_user_cash(client, cash);

stock cm_add_user_cash(client, cash)
{
return cm_add_user_cash(client, cm_get_user_cash(client) + cash);
}
stock cm_sub_user_cash(client, cash)
{
return cm_set_user_cash(client, cm_get_user_cash(client) - cash);
}

matsi 09-28-2012 13:33

Re: Moneyblock Action, help please!
 
You have two booleans on that function.

Code:
ActionMoney(id, ent) {     if ( cs_get_user_team(id) == CS_TEAM_T )     {         if ( !g_cash_used[id] )         {             emit_sound(id, CHAN_STATIC, g_sound_money, 1.0, ATTN_NORM, 0, PITCH_NORM);             new property[5];             GetProperty(ent, 1, property);                         cm_set_user_cash(id, cm_get_user_cash(id) + str_to_num(property));             cm_cash_used[id] = true;                         set_hudmessage(0, 255, 0, 0.01, 0.18, 0, 0.0, 1.0, 0.25, 0.25, 2);             show_hudmessage(id, "You got %i more Money!", str_to_num(property));         }     } }

Use one of them not both. Either create new bool:g_cash_used[ 33 ]; or use that cm_cash_used[ .. ];

( You get that error because you haven't created g_cash_used )

lukasdaman 09-28-2012 14:32

Re: Moneyblock Action, help please!
 
Fixed. Thanks.


All times are GMT -4. The time now is 08:21.

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