SA-MP Forums Archive
Problem in CMD unmute - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem in CMD unmute (/showthread.php?tid=440143)



Problem in CMD unmute - DetoNater - 28.05.2013

hi i get these warnings, here is my code
pawn Код:
CMD:unmute(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        new targetid, string[128];
        {
        if(sscanf(params, "ui", targetid)) SendClientMessage(playerid, C_GREY, "USAGE: /unmute [playerid]");

        format(string, sizeof(string), "ADMIN: %s has been un-muted.", Name(targetid));
        SendClientMessageToAll(C_YELLOW, string);
        SendClientMessage(targetid, C_LGREEN, "You are un-muted!");
        PlayerInfo[targetid][pMuted] = 0;
        }
        if(PlayerInfo[targetid][pMuted] = 1)
        //{
        SendClientMessage(playerid, C_RED, "Player muted!");
        //}
        else if(PlayerInfo[targetid][pMuted] = 0)
        //{
        SendClientMessage(playerid, C_RED, "Player not muted!");
        //}
       
    }
    else SendClientMessage(playerid, C_RED, "You are not authorized to use this command!");
    return 1;
}
Код:
>>>Warnings<<<

D:\GTA SanAndreas\_Samp_\gamemodes\iBon_BF.pwn(3699) : warning 211: possibly unintended assignment
D:\GTA SanAndreas\_Samp_\gamemodes\iBon_BF.pwn(3703) : warning 211: possibly unintended assignment
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.
Help me to fix this, thanks in advance!


Re : Problem in CMD unmute - Stefano.R - 28.05.2013

if(PlayerInfo[targetid][pMuted] == 1)
and
else if(PlayerInfo[targetid][pMuted] == 0)


Re: Problem in CMD unmute - Areax - 28.05.2013

Try this:

pawn Код:
CMD:unmute(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        new targetid, string[128];
        {
        if(sscanf(params, "ui", targetid)) SendClientMessage(playerid, C_GREY, "USAGE: /unmute [playerid]");

        format(string, sizeof(string), "ADMIN: %s has been un-muted.", Name(targetid));
        SendClientMessageToAll(C_YELLOW, string);
        SendClientMessage(targetid, C_LGREEN, "You are un-muted!");
        PlayerInfo[targetid][pMuted] = 0;
        }
        if(PlayerInfo[targetid][pMuted] == 1)
        //{
        SendClientMessage(playerid, C_RED, "Player muted!");
        //}
        else if(PlayerInfo[targetid][pMuted] == 0)
        //{
        SendClientMessage(playerid, C_RED, "Player not muted!");
        //}
       
    }
    else SendClientMessage(playerid, C_RED, "You are not authorized to use this command!");
    return 1;
}



Re: Problem in CMD unmute - jordy.kiesebrink - 28.05.2013

The difference between
pawn Код:
PlayerInfo[targetid][pMuted] = 1
and

pawn Код:
PlayerInfo[targetid][pMuted] == 1
is that with the first one you use, you are trying to check with a if statement the pMuted, But in fact you are setting it with = 1..

So to be sure you won't do it wrong anymore you should remind that == means is equel and = is setting something in this case your pMuted to 1

and in a if statement you check if someting is equeal with
Код:
== : equal
!= : not equal 
&& : and 
|| : or
< : lower then
> : higher then
>= : higher or equal
<= : lower or equal



Re: Problem in CMD unmute - DetoNater - 28.05.2013

thanks y'all it's working.


Re: Problem in CMD unmute - jordy.kiesebrink - 28.05.2013

good keep those logic operators in mind to don't confuse them again (logic operator example: && || ==)