Raised This Month: $12 Target: $400
 3% 

Solved Player bool


Post New Thread Reply   
 
Thread Tools Display Modes
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 07-04-2018 , 13:07   Re: Player bool
Reply With Quote #11

Quote:
Originally Posted by warps013 View Post
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

Warning: Loose indentation on line 48
Warning: Loose indentation on line 64
Warning: Loose indentation on line 77
Warning: Function "handlerMenu" should return a value on line 107
Warning: Symbol is assigned a value that is never used: "race_winner" on line 159
Header size: 960 bytes
Code size: 5140 bytes
Data size: 2824 bytes
Stack/heap size: 16384 bytes; estimated max. usage=57 cells (228 bytes)
Total requirements: 25308 bytes

5 Warnings.
Done.

So I tried to change it to 33 and delete [id-1] but there was some errors so place them like before (like now)

PHP Code:
if(is_user_alive(i) && timer_started[i-1]) { 
Im using i here not id

Ok, I will try get_players, thanks! Later
if u removed id-1 then why i see i-1 ?
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-04-2018 , 13:11   Re: Player bool
Reply With Quote #12

It doesn't matter if it's "id" or "i" or "asd" or anything else. What matters is that this variable holds a player id and a player id is in the range from 1 to 32. Everything outside this range will cause the plugin to fail and output an error. On the other hand, if you don't "cover" the entire range in your code, the players whose ids are missing won't get affected by the plugin.
__________________

Last edited by OciXCrom; 07-04-2018 at 13:12.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
warps013
Junior Member
Join Date: May 2018
Old 07-05-2018 , 13:55   Re: Player bool
Reply With Quote #13

Ok I changed almost all as you said for trying. A quick question,my server has a space of 12 slots, as user id, now I have 99 (so I suppose that id is the #number at left of name in status via game console). So could this number be higher than 13?

Also, tried to change get_maxplayers() to get_players() in:
PHP Code:
public timer_task() { 
 for(new 
i=1;i<=get_maxplayers();i++) { 
     if(
is_user_alive(i) && timer_started[i]) { 
         new 
Float:sec get_gametime() - timer[i], min 
         
if((sec 60.0) >= 1) { 
             
min floatround(sec 60.0,floatround_floor
             
sec -= min 60 
         

         
client_print(iprint_center "%d : %f",min ,sec)              
     } 


PHP Code:
public hamUse(entid) {
    if(!(
<= id <= get_maxplayers())) return HAM_IGNORED;
    
    new 
szTarget[32];
    
pev(entpev_targetszTarget31);
    
        if(
equal(szTarget"counter_off") || equal(szTarget"clockstopbutton") || equal(szTarget"clockstop") || equal(szTarget"stop_counter")) { 
        
stopcmd(id)
        }
        
timer_started[id] = false;
        return 
HAM_IGNORED;
    } 
But get the following error:
Quote:
Error: Number of arguments does not match definition on line 34
Error: Number of arguments does not match definition on line 68
So I checked this:
AmxModX API

And tried:
PHP Code:
get_players(playersnum"ae""CT"
So player and i are not defined, tried to replace all i to player and all player to i. But as you see I'm not understanding the syntax of get_players()

Pd: Should I change szTarget[32] to 33 too?

Last edited by warps013; 07-05-2018 at 14:05.
warps013 is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 07-05-2018 , 15:05   Re: Player bool
Reply With Quote #14

Quote:
Originally Posted by warps013 View Post
Pd: Should I change szTarget[32] to 33 too?
No, you should use [33] when this variable is for Player, otherwise set how much it needs. 32-size for string variable (szTarget) is normal.
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-05-2018 , 18:07   Re: Player bool
Reply With Quote #15

It doesn't matter how many slots you have. The player id can range from 1 to 32 and you should always use [33] when using player variables. Loop all players like this:

PHP Code:
new iPlayers[32], iPnum
get_players
(iPlayersiPnum)

for(new 
iPlayeriiPnumi++)
{
    
iPlayer iPlayers[i]
    
    
// iPlayer is the player id

You can also add filtering flags if you want only alive players, only CTs, etc.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Reply


Thread Tools
Display Modes

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 10:12.


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