Raised This Month: $ Target: $400
 0% 

[HELP] How do I loop set_task for only a few seconds.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-22-2018 , 10:53   Re: [HELP] How do I loop set_task for only a few seconds.
Reply With Quote #1

Since cs_get_user_team() returns a CsTeams type, you need to define the iPTeam variable as CsTeams. You were also missing a closing bracket. Natsheh, you should avoid calling cs_get_user_team() multiple times for the same player.

I didn't look at your code beyond this, not sure if it does what you expect. Give it a try.

Code:
public updatePlayerEconomy() {     new players[ 32 ] , playercount , player , player2 , szName[ 32 ]     new iPMoney , CsTeams:iPTeam[ 33 ];         get_players(players, playercount, "h");         for(new i ; i < playercount; i++)     {         player = players[i];                 if ( !iPTeam[ player ] )             iPTeam[ player ] = cs_get_user_team( player );                     if (CS_TEAM_T <= iPTeam[ player ] <= CS_TEAM_CT)         {             iPMoney = cs_get_user_money(player);             get_user_name(player, szName, charsmax(szName));                     for ( new j = 0 ; j < playercount ; j++ )             {                 player2 = players[j];                                 if ( !iPTeam[ player2 ] )                     iPTeam[ player2 ] = cs_get_user_team( player2 );                                     if ( iPTeam[ player ] == iPTeam[ player2 ] )                 {                     client_print( player2 , print_chat , "%s => $%d" , szName , iPMoney );                 }             }         }     } }
__________________

Last edited by Bugsy; 04-22-2018 at 11:28.
Bugsy is offline
GoldNux
Senior Member
Join Date: Mar 2018
Old 04-22-2018 , 12:08   Re: [HELP] How do I loop set_task for only a few seconds.
Reply With Quote #2

Quote:
Originally Posted by Bugsy View Post
Since cs_get_user_team() returns a CsTeams type, you need to define the iPTeam variable as CsTeams. You were also missing a closing bracket. Natsheh, you should avoid calling cs_get_user_team() multiple times for the same player.

I didn't look at your code beyond this, not sure if it does what you expect. Give it a try.

CODE...
Natshehs contribution opened up the posibility to use client_print_color, before I had an issue using it.
Even when setting the "CT" and "TERRORIST" flag, it still printed to both teams.

I wrote something that change the color of the money, to indicate what you can afford.
It is working great, but I don't think my code is very optimized.
Maybe someone can take a look?

I will later combine this with the get equipment code you wrote.

Anyways, here is the color chat code.
I know I should store get_* in variables, but when I do I get warnings and errors.
I'm obviously not doing it right.

Code:
#include <cromchat> public updatePlayerEconomy() {     new players[32], playercount, player, player2, szName[32];     get_players(players, playercount, "h");     for(new i, j, CsTeams:iPTeam, iPMoney; i < playercount; i++)     {         player = players[i];                 if (CS_TEAM_T <= (iPTeam=cs_get_user_team(player)) <= CS_TEAM_CT)         {             iPMoney = cs_get_user_money(player);             get_user_name(player, szName, charsmax(szName));                         for(j = 0; j < playercount; j++)             {                 player2 = players[j];                 if (iPTeam != cs_get_user_team(player2)) continue;                 {                     if (cs_get_user_team(player2) == CS_TEAM_T && !is_user_hltv(player2) && cs_get_user_team(player2) != CS_TEAM_SPECTATOR)                     {                         if (iPMoney < 3000)                             CC_SendMessage(player2, "%s:&x07 $ %d", szName, iPMoney)                         else if (iPMoney > 3000 && iPMoney < 3500)                             CC_SendMessage(player2, "%s:&x01 $ %d", szName, iPMoney)                         else if (iPMoney > 3500 && iPMoney < 10000)                             CC_SendMessage(player2, "%s:&x04 $ %d", szName, iPMoney)                         else if (iPMoney > 10000)                             CC_SendMessage(player2, "%s:&x06 $ %d", szName, iPMoney)                     }                     else if (cs_get_user_team(player2) == CS_TEAM_CT && !is_user_hltv(player2) && cs_get_user_team(player2) != CS_TEAM_SPECTATOR)                     {                         if (iPMoney < 3250)                             CC_SendMessage(player2, "%s:&x07 $ %d", szName, iPMoney)                         else if (iPMoney > 3250 && iPMoney < 4100)                             CC_SendMessage(player2, "%s:&x01 $ %d", szName, iPMoney)                         else if (iPMoney > 4100 && iPMoney < 10000)                             CC_SendMessage(player2, "%s:&x04 $ %d", szName, iPMoney)                         else if (iPMoney > 10000)                             CC_SendMessage(player2, "%s:&x06 $ %d", szName, iPMoney)                     }                 }             }         }     } }
__________________
Try my version of de_dust2, I think it's great and you should check it out!
https://gamebanana.com/mods/83731

Last edited by GoldNux; 04-22-2018 at 12:43.
GoldNux is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-22-2018 , 13:21   Re: [HELP] How do I loop set_task for only a few seconds.
Reply With Quote #3

Quote:
Originally Posted by Bugsy View Post
Since cs_get_user_team() returns a CsTeams type, you need to define the iPTeam variable as CsTeams. You were also missing a closing bracket. Natsheh, you should avoid calling cs_get_user_team() multiple times for the same player.

I didn't look at your code beyond this, not sure if it does what you expect. Give it a try.

Code:
public updatePlayerEconomy() {     new players[ 32 ] , playercount , player , player2 , szName[ 32 ]     new iPMoney , CsTeams:iPTeam[ 33 ];         get_players(players, playercount, "h");         for(new i ; i < playercount; i++)     {         player = players[i];                 if ( !iPTeam[ player ] )             iPTeam[ player ] = cs_get_user_team( player );                     if (CS_TEAM_T <= iPTeam[ player ] <= CS_TEAM_CT)         {             iPMoney = cs_get_user_money(player);             get_user_name(player, szName, charsmax(szName));                     for ( new j = 0 ; j < playercount ; j++ )             {                 player2 = players[j];                                 if ( !iPTeam[ player2 ] )                     iPTeam[ player2 ] = cs_get_user_team( player2 );                                     if ( iPTeam[ player ] == iPTeam[ player2 ] )                 {                     client_print( player2 , print_chat , "%s => $%d" , szName , iPMoney );                 }             }         }     } }
Well actually i didnt really compiled the code neither tested it, it was written on a phone..

The code should function correctly.

Btw goldnux remove the bracket "{" after continue; and its close
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 04-22-2018 at 14:23.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:39.


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