Player bool
Hi, I'm trying to find out something like how to set a bool for a specific player. I'm goint to show you my code to have a basic idea of what I want todo, also I know code is totally wrong. So please try to solve just this question. How could I define a "race_creator" for a player an there only can be 1 "race_creator"
PHP Code:
So I know I have to fix a lot the structure of the plugin, but first I want to know that. Thanks! |
Re: Player bool
Variant A:
new bool:race_creator => new bool:race_creator[33] how to get specified players race_creator? use race_creator[id] and not race_creator how to set specified players race_creator? race_creator[id] = X Variant B (Because its bool, you can also use bit sums): new race_creator how to get specified players race_creator? if (race_creator & (1 << id)) how to set specified players race_creator? race_creator |= (1 << id) how to remove specified players race_creator? race_creator &= ~(1 << id) (Believe me, first one is easier) |
Re: Player bool
I'm not going to look at the entire code, but I want to let you know that instead of using 32 as an array size in the global variables, you should be using 33. The way you have it right now, the 32nd player will break the plugin.
timer_started[32] => timer_started[33] Btw, this bool is already an example of what you're trying to do. |
Re: Player bool
Yes, now that you mentioned it you are right. Since I copy that part I didn't noticed it.
Thanks both for the help, also I'm going to change it to 33. :) |
Re: Player bool
Also, use [id], not [id-1].
|
Re: Player bool
[32] & id-1 => the best way to shorten memory with 4 bytes. :D
|
Re: Player bool
Quote:
|
Re: Player bool
So far, this is how code looks like
PHP Code:
|
Re: Player bool
PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
I'm not going to look further since you probably didn't fix everything yet. |
Re: Player bool
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:
Ok, I will try get_players, thanks! Later :fox: |
All times are GMT -4. The time now is 02:49. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.