AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   if, elseif, bool? (https://forums.alliedmods.net/showthread.php?t=237188)

Garrey 03-19-2014 18:03

if, elseif, bool?
 
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");
    }
    



Black Rose 03-19-2014 18:08

Re: if, elseif, bool?
 
It kind of depends on what you mean by "this"?

Garrey 03-19-2014 18:17

Re: if, elseif, bool?
 
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".

Black Rose 03-19-2014 18:23

Re: if, elseif, bool?
 
I can't say anything about the mute function. It might be blocked by valve for all I know.
But the code looks good.

YamiKaitou 03-19-2014 18:35

Re: if, elseif, bool?
 
Code:

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

:arrow:
Code:

    if (g_mute[i]) {
        set_user_info(i, "mute", "off")
    }
    else {
        set_user_info(i, "mute", "on")
    }

See if this makes a difference

OnePL 03-19-2014 20:43

Re: if, elseif, bool?
 
Quote:

Originally Posted by YamiKaitou (Post 2113636)
Code:

    if (g_mute[i]) {
        set_user_info(i, "mute", "off")
    }
    else {
        set_user_info(i, "mute", "on")
    }

See if this makes a difference

:arrow:

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")
    }



Garrey 03-20-2014 03:49

Re: if, elseif, bool?
 
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

baneado 03-20-2014 13:03

Re: if, elseif, bool?
 
@OnePL
PHP Code:

(!is_user_connected(i)) continue 

-->
PHP Code:

if (!is_user_connected(i)) continue 



All times are GMT -4. The time now is 06:00.

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