Raised This Month: $ Target: $400
 0% 

Problem with setting boolean...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rolnaaba
Veteran Member
Join Date: May 2006
Old 06-02-2007 , 17:47   Problem with setting boolean...
Reply With Quote #1

This is code from my SuperNade plugin:
Code:
register_forward(FM_EmitSound, "EmitSound"); register_clcmd("/nade", "buy_nade"); public buy_nade(id) {     if(!get_pcvar_num(pcvar[CMOD])) {         client_print(id, print_chat, "SuperNade Disabled by Admin, sry :(");         return PLUGIN_HANDLED;     }     if(!is_user_alive(id) || !is_user_connected(id)) {         client_print(id, print_chat, "You must be alive to buy a SuperNade!");         return PLUGIN_HANDLED;     }     if(cs_get_user_team(id) == CS_TEAM_SPECTATOR || cs_get_user_team(id) == CS_TEAM_UNASSIGNED) {         client_print(id, print_chat, "You must be on a team to buy a SuperNade!");         return PLUGIN_HANDLED;     }     if(HasSuperNade[id-1]) {         client_print(id, print_chat, "You already have a supernade!");         return PLUGIN_HANDLED;     }     if(cs_get_user_money(id) < get_pcvar_num(pcvar[CCOST])) {         client_print(id, print_chat, "You cant afford to buy a SuperNade! It cost: %i", get_pcvar_num(pcvar[CCOST]));         return PLUGIN_HANDLED;     }     cs_set_user_money(id, cs_get_user_money(id)-get_pcvar_num(pcvar[CCOST]), 1);         new wpnids[32], num;     get_user_weapons(id, wpnids, num);         new bool:has;         for(new i = 0; i < num; i++) {         if(wpnids[i] == CSW_HEGRENADE) {             has = true;         }     }         if(!has) {         give_nade(id);     }     HasSuperNade[id-1] = true;         client_print(id, print_chat, "You now hold a SuperNade...be careful!!");         return PLUGIN_HANDLED; } public EmitSound(entity, channel, const sound[]) {     if(!get_pcvar_num(pcvar[CMOD]))         return FMRES_IGNORED;             if(!pev_valid(entity))         return FMRES_IGNORED;         if(contain(sound, "debris") == -1)         return FMRES_IGNORED;         new Float:origin[3], owner;         pev(entity, pev_origin, origin);     owner = pev(entity, pev_owner);         //extend the nade's range     if(!HasSuperNade[owner])         return FMRES_IGNORED;     HasSuperNade[owner] = false;     extend_range(origin);     if(!Planted)         return FMRES_IGNORED;             //search entities around the nade explosion     new ent = -1     while((ent = engfunc(EngFunc_FindEntityInSphere, ent, origin, get_pcvar_float(pcvar[CRADIUS]))) != 0) {         if(!pev_valid(ent))             continue                 //get classname of entity         static Classname[33]         pev(ent, pev_classname, Classname, 32)                     //make sure is grenade entity, and is the c4 grenade         if(!equal(Classname,g_Classname) || fm_cs_get_grenade_type(ent) != CSW_C4)             continue         set_pdata_float(ent, 100, 0.0); //makes the c4 entity explode     }     return FMRES_IGNORED;   }

Now when I am in the server by myself and I type /buy in chat my id is returned as "1", I know this because I had many client prints telliing me everything that was happening during testing, but later when I throw it, and pev() gets the owner, my id is returned as "0". so to remedy this problem I did HasSuperNade[id-1] = true; on buy function and it works fine, if I am only person in server. If others are tho, the person with id=1 can buy multiple nades per round, but everyone else cant, it isnt setting false correctly on them, what is the problem?
__________________
DO NOT PM me about avp mod.

Last edited by Rolnaaba; 06-02-2007 at 17:55.
Rolnaaba is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 06-02-2007 , 17:56   Re: Problem with setting boolean...
Reply With Quote #2

i.e.: if your id #1, you can buy a nade throw it and buy another, if you have enough money.
but if you are not id #1, you can buy a nade throw it, and it keeps saying that you already have a nade, which means it is not placing it as false on other people.
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
Old 06-02-2007, 18:30
organizedKaoS
This message has been deleted by organizedKaoS.
Zenith77
Veteran Member
Join Date: Aug 2005
Old 06-02-2007 , 18:44   Re: Problem with setting boolean...
Reply With Quote #3

Code:
id-1

Why are you doing this? If pev_owner is returning zero, the perhaps it does not store the "owner" of the grenade in that field. Valid player indexs are 1-32.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred

Last edited by Zenith77; 06-02-2007 at 18:47.
Zenith77 is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 06-02-2007 , 18:57   Re: Problem with setting boolean...
Reply With Quote #4

Quote:
Originally Posted by organizedKaoS View Post
Set the boolean per id this way...

new bool:hasNade[33]

hasNade[id] = true

Also declare the bool as a global variable, not inside the function.

In putinserver and disconnect set the bool[id] to false.
duh I am doing that, i am not THAT big of a n00b


Quote:
Originally Posted by Zenith77 View Post
Code:
id-1
Why are you doing this? If pev_owner is returning zero, the perhaps it does not store the "owner" of the grenade in that field. Valid player indexs are 1-32.
well do you have another way to get the owner of an exploded grenade?
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
Old 06-03-2007, 03:57
organizedKaoS
This message has been deleted by organizedKaoS.
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 06-03-2007 , 04:21   Re: Problem with setting boolean...
Reply With Quote #5

Probably your problem is here:

PHP Code:
owner pev(entitypev_owner);
 
    
//extend the nade's range
    
if(!HasSuperNade[owner]) 
        return 
FMRES_IGNORED;
    
HasSuperNade[owner] = false
Note that you did this:
PHP Code:
HasSuperNade[id-1] = true
Solution?
PHP Code:
HasSuperNade[owner-1
Edit:

since new bool:HasSuperNade[33] (in your plugin thread). An easier way it just to remove all the -1 in HasSuperNade[id-1].
__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.

Last edited by Cheap_Suit; 06-03-2007 at 04:28.
Cheap_Suit is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 06-03-2007 , 12:55   Re: Problem with setting boolean...
Reply With Quote #6

ok both of you are wrong, sorry but have to say it. Organized is talking about the wrong boolean, the HasSuperNade bool is what I am tlaking about. It IS global. The reason it is not setting right was because my pev_owner, is returning "0", because the nade is already removed it cannot find an owner. So neither of your solutions will work. I have solved this problem already but thanks anyway.
And btw, this:
Code:
new wpnids[32], num;     get_user_weapons(id, wpnids, num);         new bool:has;         for(new i = 0; i < num; i++) {         if(wpnids[i] == CSW_HEGRENADE) {             has = true;         }     }
Has nothing to do with if they have a supernade or not, this is to cycle through their weapons and detemine if they have an HEGRENADE already or if I need to give them one. but I am not using this code block anymore anyway so thanks again but not even close to what I was tlaking about.
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 06-03-2007 , 12:58   Re: Problem with setting boolean...
Reply With Quote #7

Zenith77 had nailed it when he said:

Quote:
Originally Posted by Zenith77 View Post
Code:
id-1
Why are you doing this? If pev_owner is returning zero, the perhaps it does not store the "owner" of the grenade in that field. Valid player indexs are 1-32.
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 06-03-2007 , 13:26   Re: Problem with setting boolean...
Reply With Quote #8

If you misunderstood me, I was pointing out the problem in the HasSuperNadearray.
__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.
Cheap_Suit is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 06-03-2007 , 16:48   Re: Problem with setting boolean...
Reply With Quote #9

I know but it wasnt the error you were thinking of, it was a problem with pev_owner, not the indexed array
__________________
DO NOT PM me about avp mod.
Rolnaaba 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 10:44.


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