AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Boolean not changing (https://forums.alliedmods.net/showthread.php?t=296129)

heroicpower7613 04-13-2017 03:52

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

Spoiler

HamletEagle 04-13-2017 04:16

Re: Boolean not changing
 
There is no id passed from HLTV event.

Lord Nightmare 04-13-2017 04:17

Re: Boolean not changing
 
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;
}


heroicpower7613 04-13-2017 04:22

Re: Boolean not changing
 
thanks alot

HamletEagle 04-13-2017 06:58

Re: Boolean not changing
 
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).

heroicpower7613 04-17-2017 12:10

Re: Boolean not changing
 
Quote:

Originally Posted by HamletEagle (Post 2511732)
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?

Natsheh 04-17-2017 12:59

Re: Boolean not changing
 
Quote:

Originally Posted by heroicpower7613 (Post 2512963)
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

Craxor 04-17-2017 15:20

Re: Boolean not changing
 
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.

EFFx 04-17-2017 15:26

Re: Boolean not changing
 
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.

Craxor 04-17-2017 15:31

Re: Boolean not changing
 
Quote:

Originally Posted by EFFx (Post 2513023)
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.

It may be wierd and some people will be against me but i prefer to personaly explain something to somebody ( or sombody to me ) rather than giving him a link or telling him to search on google ( only if is about to lot of necesary study ) but for simple things i don't mad ( only my opionion ofcourse ... anyway is better to sarch by yourself for what you need ) .


All times are GMT -4. The time now is 18:03.

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