Getting global data from non-id publics
Hello! I am wondering how could i retrieve global id saved variable to a public whom doesn't have the typical id index.
Example : PHP Code:
I have seen some plugins which used get_players for retrieving gobal data like that but it seemed pretty much situational, since in this example i don't see logic on how get_players will work. Although i guess i could set a variable to hold the player's Id i guess. Like so PHP Code:
|
Re: Getting global data from non-id publics
I would avoid the temp_id method since it will not be reliable. There's nothing wrong with checking all players at round end using get_players(). What are you confused about? Round end is not a player-specific event so you cannot get a single player id for it. You need to loop through all players and react on them based on conditions.
PHP Code:
|
Re: Getting global data from non-id publics
I see, but won't that trigger the client print to everybody if just One player has the value?
|
Re: Getting global data from non-id publics
Quote:
Code:
client_print( iPlayer , print_chat, "Retrieved player's variable") Maybe this will help clear your confusion. The code below is functionally equivalent to what Bugsy did, but now you have an explicit function, player_round_end(id), that takes the player index as an argument. Hope it will help you see why this works just fine. The loop is over all players, but you still execute the code over one player at a time. (I'm not saying you should use the code below, I just provided it for intuition) PHP Code:
|
Re: Getting global data from non-id publics
Basically get_players is the same as looping players indexes from 1 to 32 except its done in a module which is much faster
PHP Code:
|
Re: Getting global data from non-id publics
Quote:
The speed with a loop that runs at most 32 times is irrelevant. Even if running the loop in a module may be very slightly faster, as a whole get_players is likely slower than just looping from 1 to max players and checking. With get_players there is a loop inside the module, then there is the pawn c++ interop time and then you loop again in plugin over the results from get_players(which may be less than 32 because of filtering/the server is not full). But this is not an issue, because as I said previously, speed is not why get_players is recommended. |
Re: Getting global data from non-id publics
Aah, i get it!
Thank you lots. :fox: |
Re: Getting global data from non-id publics
Quote:
Grenade Suicide example.
Spoiler
Code:
Quote:
Code:
Later is identical just more prudent. Back to getting index within a function without it. They have to do something first and it be logged. Then the stock can extract the index for use. |
All times are GMT -4. The time now is 08:32. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.