Problem in CMD unmute
#1

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!
Reply
#2

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

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;
}
Reply
#4

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
Reply
#5

thanks y'all it's working.
Reply
#6

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


Forum Jump:


Users browsing this thread: 1 Guest(s)