Raised This Month: $ Target: $400
 0% 

Boolean not changing


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
heroicpower7613
Member
Join Date: Nov 2016
Old 04-13-2017 , 03:52   Boolean not changing
Reply With Quote #1

why is this boolean not changing on new round?
how to fix it?

Spoiler
heroicpower7613 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-13-2017 , 04:16   Re: Boolean not changing
Reply With Quote #2

There is no id passed from HLTV event.
__________________
HamletEagle is offline
Lord Nightmare
Junior Member
Join Date: Feb 2014
Location: Poland
Old 04-13-2017 , 04:17   Re: Boolean not changing
Reply With Quote #3

Because the NewRound Event dont storage ID of Player
You must create id like here :

Code:
/* Plugin generated by AMXX-Studio */ 
  
#include <amxmodx> 
#include <amxmisc> 
  
#define PLUGIN "New Round" 
#define VERSION "1.0" 
#define AUTHOR "Admin" 

#define MAXPLAYERS 32

new bool:g_Newround[33] = false;
  
public plugin_init() 
{ 
    register_plugin(PLUGIN, VERSION, AUTHOR);
    register_clcmd("say /bool", "cmdBool");
    register_event("HLTV", "NewRound", "a", "1=0", "2=0");
} 

public client_authorized(id) 
{ 
    g_Newround[id] = false; 
} 

public NewRound() 
{ 
    for(new id = 1; id <= MAXPLAYERS; id++){
    
         client_print(id, print_chat, "NewRound")   
         g_Newround[id] = true;
    }
} 

public cmdBool(id) 
{ 
    if(!g_Newround[id]) 
    { 
        client_print(id, print_chat, "false");
    } 
    else 
    { 
        client_print(id, print_chat, "true");
    } 
    return PLUGIN_CONTINUE; 
}
Lord Nightmare is offline
heroicpower7613
Member
Join Date: Nov 2016
Old 04-13-2017 , 04:22   Re: Boolean not changing
Reply With Quote #4

thanks alot
heroicpower7613 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-13-2017 , 06:58   Re: Boolean not changing
Reply With Quote #5

No, not like he's showing you. This is the proper way:
PHP Code:
new Players[32], PlayersNum
get_players
(PlayersPlayersNum)
new 
id

for(new iPlayersNumi++)
{
    
id Players[i]
    
g_Newround[id] = true

For what are you using g_Newround? It looks like it should not be an array(i.e. simply new g_Newround/ g_Newround = true will work).
__________________
HamletEagle is offline
heroicpower7613
Member
Join Date: Nov 2016
Old 04-17-2017 , 12:10   Re: Boolean not changing
Reply With Quote #6

Quote:
Originally Posted by HamletEagle View Post
No, not like he's showing you.


For what are you using g_Newround? It looks like it should not be an array(i.e. simply new g_Newround/ g_Newround = true will work).
it needs to be true or false for specific players, that's why there should be id?
what's wrong with the way Lord showed?
heroicpower7613 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-17-2017 , 12:59   Re: Boolean not changing
Reply With Quote #7

Quote:
Originally Posted by heroicpower7613 View Post
it needs to be true or false for specific players, that's why there should be id?
what's wrong with the way Lord showed?
First of all, whats lord is doing, hes looping all players slots, including the non existing one's, and printing msgs which will throw an error because sending to unconnected players. And the server slots might not be 32
__________________
@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-17-2017 at 12:59.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Old 04-17-2017, 15:12
Craxor
This message has been deleted by Craxor. Reason: Nvm, i'm wrong.
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 04-17-2017 , 15:20   Re: Boolean not changing
Reply With Quote #9

Let me tell you in a different way ....


'0' is the index of the server...
Players have an id from '1' to '32' ( depends of the connected players of the server ... example if they are 16 players connected they will be 16 indexes on the server, from 1 to 16 ) .

get_players() take all the indexes in an array and insert them ... if you use get_players() you will get only the connected and existing indexes ( you can also separate them using the flags, example : get the indexes only of alive players, only of spectators .. etc ) ... if you will do a LOOp from 1 to 32 will you teach each index from 1 to 32 and now think if they are only 5 players ... the loop will continue to touch it. .. even if they are not existing ... and that's will throw an error to your server.
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 04-17-2017 , 15:26   Re: Boolean not changing
Reply With Quote #10

There are a lot of posts about that question here. Will we keep saying the same thing everytime? People should see the power of the google search before post/ask something.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
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 18:03.


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