Raised This Month: $ Target: $400
 0% 

if, elseif, bool?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Garrey
Member
Join Date: Jan 2010
Old 03-19-2014 , 18:03   if, elseif, bool?
Reply With Quote #1

Hei guys.. wanted to ask is this possible?

PHP Code:
new bool:g_mute[33];

public 
plugin_init()
{    
    
set_task(120.0"ShowMessage");
    
    
register_clcmd("say /us""cmdToggle")
    return 
PLUGIN_CONTINUE
}
public 
cmdToggle(i){
    
g_mute[i] = !g_mute[i];
    if ((
g_mute[i] = true)) {
        
client_cmd(i"setinfo ^"mute^" ^"off^"")
    }
    else if ((
g_mute[i] = false)) {
        
client_cmd(i"setinfo ^"mute^" ^"on^"")
    }
    
    
ColorChat(i"^3You have^4 %sabled^3 sounds",(g_mute[i] ? "en":"dis") );
}
public 
ShowMessage(i) {
    if((
g_mute[i] = true)) {
        
ColorChat(i"^3To turn ^4OFF^3 sounds - say ^1/us");
    }
    else {
        
ColorChat(i"^3To turn ^4ON^3 sounds - say ^1/us");
    }
    

__________________
People are like music, some speak the truth and others are just noise..
Garrey is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 03-19-2014 , 18:08   Re: if, elseif, bool?
Reply With Quote #2

It kind of depends on what you mean by "this"?
__________________
Black Rose is offline
Garrey
Member
Join Date: Jan 2010
Old 03-19-2014 , 18:17   Re: if, elseif, bool?
Reply With Quote #3

I mean, if I say "/us" then it will make client_cmd with "setinfo mute off" and if he say /us again.. it will replace with "setinfo mute on".
__________________
People are like music, some speak the truth and others are just noise..
Garrey is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 03-19-2014 , 18:23   Re: if, elseif, bool?
Reply With Quote #4

I can't say anything about the mute function. It might be blocked by valve for all I know.
But the code looks good.
__________________
Black Rose is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 03-19-2014 , 18:35   Re: if, elseif, bool?
Reply With Quote #5

Code:
    if ((g_mute[i] = true)) { 
        client_cmd(i, "setinfo ^"mute^" ^"off^"") 
    } 
    else if ((g_mute[i] = false)) { 
        client_cmd(i, "setinfo ^"mute^" ^"on^"") 
    }

Code:
    if (g_mute[i]) { 
        set_user_info(i, "mute", "off") 
    } 
    else { 
        set_user_info(i, "mute", "on") 
    }
See if this makes a difference
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
OnePL
BANNED
Join Date: May 2012
Location: GB
Old 03-19-2014 , 20:43   Re: if, elseif, bool?
Reply With Quote #6

Quote:
Originally Posted by YamiKaitou View Post
Code:
    if (g_mute[i]) { 
        set_user_info(i, "mute", "off") 
    } 
    else { 
        set_user_info(i, "mute", "on") 
    }
See if this makes a difference


Code:
set_user_info(i, "mute", g_mute[i] ? "off" : "on")
PHP Code:
new maxplbool:g_mute[33]; 

public 
plugin_init() {
    
register_clcmd("say /us""cmdToggle")

    
set_task(120.0"ShowMessage")
    
maxpl get_maxplayers()


public 
cmdToggle(id) {
    
g_mute[i] = !g_mute[i]
    
set_user_info(id"mute"g_mute[i] ? "on" "off")
    
ColorChat(id"You have ^3%sable^1 sounds."g_mute[id] ? "en" "dis")
}

public 
ShowMessage() {
    for(new 
1<= maxpli++) {
        (!
is_user_connected(i)) continue

        
ColorChat(i"To turn^3 O%s^1 sounds - say ^4/us"g_mute[i] ? "FF" "N")
    }


Last edited by OnePL; 03-19-2014 at 20:51.
OnePL is offline
Send a message via ICQ to OnePL Send a message via AIM to OnePL Send a message via Yahoo to OnePL Send a message via Skype™ to OnePL
Garrey
Member
Join Date: Jan 2010
Old 03-20-2014 , 03:49   Re: if, elseif, bool?
Reply With Quote #7

PHP Code:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c1997-2013 ITB CompuPhaseAMX Mod X Team

Error
Expected token";"but found "continue" on line 199
Warning
Unreachable code on line 201

1 Error

Mhh.. and how can i check if those sounds are ON or OFF when users connects? I mean how can i check setinfo and if the sounds are on then it will users
g_mute[i] = true or other
__________________
People are like music, some speak the truth and others are just noise..
Garrey is offline
baneado
Veteran Member
Join Date: Dec 2012
Location: amxmodx-es.com
Old 03-20-2014 , 13:03   Re: if, elseif, bool?
Reply With Quote #8

@OnePL
PHP Code:
(!is_user_connected(i)) continue 
-->
PHP Code:
if (!is_user_connected(i)) continue 
baneado 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 06:00.


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