AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   arrg, somebody help plz (https://forums.alliedmods.net/showthread.php?t=49940)

tadoom 01-16-2007 01:12

arrg, somebody help plz
 
I want to replace a cs function (cs_get_user_money) with my own (g_money) but when I go to compile it doesent work. The g_money is from my tfc money plugin.

XxAvalanchexX 01-16-2007 01:44

Re: arrg, somebody help plz
 
We'll need to see your code.

Also, why are you replacing a function? Why not just use it?

tadoom 01-16-2007 01:49

Re: arrg, somebody help plz
 
Im not using that function becuase I cant, its a cstrike one and im playing on tfc. I got a tfc money plugin going and I wanted to port the ice grenade plugin to tfc using well... the money plugin I have instead of cs functions I cant use. my code is...

Code:
public moneyforfrags() {  new iPlayers[32],iNum  get_players(iPlayers,iNum)  for(new i=0;i<iNum;i++)  {   new id=iPlayers[i]   if(is_user_connected(id))   {    if(get_user_frags(id)>lastfrags[id])    {     new hv=g_money[id]+=(get_user_frags(id)-lastfrags[id])*5     g_money[id]+=(get_user_frags(id)-lastfrags[id])*5     lastfrags[id]=get_user_frags(id)     client_print(id,print_chat,"You gained $%i.",hv)    }   }  } }

Thats just part of it but it seems like the only part you need.

All the money commands have used g_money

tadoom 01-16-2007 01:54

Re: arrg, somebody help plz
 
oh yeah and the other plugin is....

Code:
 public buy_frostnade(id)  {  if(!get_cvar_num("fn_on"))   return PLUGIN_CONTINUE;  // no custom buy needed  if(get_cvar_num("fn_override"))   return PLUGIN_HANDLED;  // not enough moneh  new money = g_money(id);  if(money < get_cvar_num("fn_price"))  {   client_print(id,print_center,"Not enough money");   return PLUGIN_HANDLED;  }  // already have a frost grenade  if(hasFrostNade[id])  {   client_print(id,print_center,"Already own fs.");   return PLUGIN_HANDLED;  }  // already have a smoke grenade  new weapons[32], num, i;  get_user_weapons(id,weapons,num);  for(i=0;i<num;i++)  {   if(weapons[i] == TFC_WPN_NORMALGRENADE)   {    client_print(id,print_center,"You already own a normal grenade.");    return PLUGIN_HANDLED;   }  }  // gimme gimme  hasFrostNade[id] = 1;  give_item(id,"weapon_normalgrenade");  g_money(id,money - get_cvar_num("fn_price"));  // display icon  message_begin(MSG_ONE,get_user_msgid("StatusIcon"),{0,0,0},id);  write_byte(1); // status (0=hide, 1=show, 2=flash)  write_string("dmg_cold"); // sprite name  write_byte(FROST_R); // red  write_byte(FROST_G); // green  write_byte(FROST_B); // blue  message_end();  return PLUGIN_HANDLED;  }

Salepate 01-16-2007 02:09

Re: arrg, somebody help plz
 
What about g_money ? how can you use :
Code:
public buy_frostnade(id) {     g_money[id]+=(get_user_frags(id)-lastfrags[id])*5;
}
and
Code:
public moneyforfrags() {     g_money(id, money - get_cvar_num("fn_price")); }
at a same time ? Isn't money a function ?

Besides declaring a variable in a loop will generate an error.
Code:
for ( new i = 0 ; i <iNum ; i ++ ) {     new id = iPlayers[i]; }
must be :
Code:
new id; for ( new i = 0 ; i <iNum ; i ++ ) {     id = iPlayers[i]; }

dutchmeat 01-16-2007 05:01

Re: arrg, somebody help plz
 
show us g_money, cause you are first using one argument, and then two...
Salepate is right about the player loop, although i would've used iPlayers[i] instead of making a new variable...
Also, a variable can't have the same name as a function...

XxAvalanchexX 01-16-2007 17:05

Re: arrg, somebody help plz
 
By the first function you posted, it looks like g_money is a variable, not a function. So change this:

Code:
 new money = g_money(id);

To this:

Code:
 new money = g_money[id];

tadoom 01-16-2007 19:44

Re: arrg, somebody help plz
 
Thanks guys, I will try all this out soon. Im horrid at coding I know :cry:

Bad_Bud 01-17-2007 01:42

Re: arrg, somebody help plz
 
Just remember the brackets are when you're storing data, and the parenthesis are for when you're calling a function and passing in that data.


All times are GMT -4. The time now is 22:25.

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