AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Get teams money (https://forums.alliedmods.net/showthread.php?t=89189)

havox 04-03-2009 12:24

[HELP] Get teams money
 
hi guys,

I'm quiet new to amxmodx scripting, but i have experience with programming.
I was scripting a plugin for counter-strike, to see each players (on your team)
money.

But the thing is.. its only showing it for the first player, like i'm player 1 in the players[32] array and after the loop it stops.

My question is, could a exp amxmodx scripter take a look into my code to see if i've done something wrong?

Thx in advance

Code:
      <font face="monospace">#include <amxmodx> #include <amxmisc> #include <fun> #include <engine> #include <cstrike> #define PLUGIN    "simple wartool" #define AUTHOR    "havox" #define VERSION    "0.1 beta" new players[11], num public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_clcmd("say_team money", "give_user_money", 0, "- displays money")     } public give_user_money() {     get_players(players, num)     new i     for(i=0;i<num;i++)     {         if(get_user_team(players[i]) == 1)         {             new y             new Float:height = 0.35             for(y=0;y<num;y++)             {                 if(get_user_team(players[y]) == 1)                 {                     new moneyData = cs_get_user_money(players[y])                     new playersName[18]                     get_user_name(players[y], playersName, 17)                     set_hudmessage(255, 255, 0, -2.0, height, 0, 0.0, 8.0, 0.1, 0.1, 1)                     show_hudmessage(players[i], "%s has: %i ", playersName, moneyData)                     height -= 0.10                 }             }         }         else         {             new y             new Float:height = 0.35             for(y = 0; y < num; y++)             {                 if(get_user_team(players[y]) == 2)                 {                     new moneyData = cs_get_user_money(players[y])                     new playersName[18]                     get_user_name(players[y], playersName, 17)                     set_hudmessage(255, 255, 0, -2.0, height, 0, 0.0, 8.0, 0.1, 0.1, 1)                     show_hudmessage(players[i], "%s has: %i ", playersName, moneyData)                     height -= 0.10                 }             }         }         }     return PLUGIN_HANDLED } </font>


Emp` 04-03-2009 12:51

Re: [HELP] Get teams money
 
There are 4 hud channels for hud messages. The last parameter of set_hudmessage is the channel and you set it to 1. So it is overwriting the last one displayed. If you do not specify (or set it to 4) it will select the next available hud channel.

Though my suggestion would be to combine all the strings into one string (each string separated by a new line ^n) and show the one string. This way you would only be using one channel instead of all 4 channels.

ConnorMcLeod 04-03-2009 13:21

Re: [HELP] Get teams money
 
Quote:

Originally Posted by Emp` (Post 796328)
If you do not specify (or set it to 4)

You mean "or set it to -1" ?

Emp` 04-03-2009 13:24

Re: [HELP] Get teams money
 
Quote:

Originally Posted by ConnorMcLeod (Post 796353)
You mean "or set it to -1" ?

Either works I believe.

xPaw 04-03-2009 13:26

Re: [HELP] Get teams money
 
The hud channels is 1, 2, 3, 4.
Quote:

Originally Posted by FuncWiki
setting the channel to -1 will automatically choose the next available HUD channel for a player.


Emp` 04-03-2009 13:28

Re: [HELP] Get teams money
 
Code:

native set_hudmessage(red=200, green=100, blue=0, Float:x=-1.0, Float:y=0.35, effects=0, Float:fxtime=6.0, Float:holdtime=12.0, Float:fadeintime=0.1, Float:fadeouttime=0.2,channel=4);
Why is default value at 4 then?

xPaw 04-03-2009 13:32

Re: [HELP] Get teams money
 
i think because standart amxx plugins using 1 or 2 afaik. so they will not mess, and developers did standart as 4.

and if you would read description for native, you will see again about -1.
PHP Code:

/**
 * Sets format for hudmessage. 
 * Note - as of AMX Mod X 1.61, setting the channel to -1
 *  will automatically choose the next available HUD channel for a player.
 */
native set_hudmessage(red=200green=100blue=0Float:x=-1.0Float:y=0.35effects=0Float:fxtime=6.0Float:holdtime=12.0Float:fadeintime=0.1Float:fadeouttime=0.2,channel=4); 


Emp` 04-03-2009 13:37

Re: [HELP] Get teams money
 
Good enough for me. I think I use -1 in all my plugins, I just went to the .inc file really quick to get the value (should have read the comment as you pointed out).

ConnorMcLeod 04-03-2009 13:46

Re: [HELP] Get teams money
 
.inc should be updated with -1 value then.

xPaw 04-03-2009 13:55

Re: [HELP] Get teams money
 
you are right connor, post this in bugs @ amxx, as suggestion


All times are GMT -4. The time now is 02:20.

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