Annoying warning
#1

Hello, addicted samp scripters!
I have one little question about one line that gives me a warning.

This line else if(PLAYER_STATE_ONFOOT)
is showing me this warning warning 206: redundant test: constant expression is non-zero

I can't understand why is that so.
Reply
#2

pawn Код:
else if (GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
Try that.
Reply
#3

PLAYER_STATE_ONFOOT is defined as 1. It's like doing:
pawn Код:
else if(1)
Check if the player's state (GetPlayerState) is equal to PLAYER_STATE_ONFOOT.
Reply
#4

Yah, thanks to you both, guys, everything seems alright!
Reply
#5

So, the next is the race command. I tryed do that in many ways, searched aswell, but nothing. Ok, the command is;

Код:
 if (strcmp("/joinrace", cmdtext, true, 10) == 0)
    {
    if(IsPlayerInStreamedCheckpoint(playerid,Cp1) && IsPlayerInAnyVehicle(playerid))
    {
    SendClientMessage(playerid,COLOR_LIGHTBLUE,"You joined the race!");
    new vehicleid = GetPlayerVehicleID(playerid);
    SetVehiclePos(vehicleid, 2466.4861,-1661.6304,12.8521);
    SetPlayerFacingAngle(playerid, 0);
    ++racers;
    joined[playerid] = true;
    }
    else if(PLAYER_STATE_ONFOOT && IsPlayerInStreamedCheckpoint(playerid,Cp1))
    {
    SendClientMessage(playerid,COLOR_LIGHTBLUE,"You must be at the cp to do that!");
    }
    else if(IsPlayerInAnyVehicle(playerid))
    {
    SendClientMessage(playerid,COLOR_LIGHTBLUE,"You must be at the cp to do that!");
    }
    else if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
    SendClientMessage(playerid,COLOR_LIGHTBLUE,"You must be at the cp to do that!");
    }
    if(joined[playerid] == true)
    {
    SendClientMessage(playerid,COLOR_LIGHTBLUE,"You already joined the race!");
    }
    return 1;
    }
So, the problem is that, i can't figure out how can i add correctly
Код:
SendClientMessage(playerid,COLOR_LIGHTBLUE,"You already joined the race!");
and it's always showing together with the
Код:
SendClientMessage(playerid,COLOR_LIGHTBLUE,"You joined the race!");
I would like to know, what i'm doing wrong with the if's and else if's, i know, i'm doing wrong.
Reply
#6

pawn Код:
if (!strcmp(cmdtext, "/joinrace", true, 9))
{
    if (joined[playerid]) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"You already joined the race!");
    if (IsPlayerInStreamedCheckpoint(playerid,Cp1) && IsPlayerInAnyVehicle(playerid))
    {
        SendClientMessage(playerid,COLOR_LIGHTBLUE,"You joined the race!");
        SetVehiclePos(GetPlayerVehicleID(playerid), 2466.4861,-1661.6304,12.8521);
        SetPlayerFacingAngle(playerid, 0);
        ++racers;
        joined[playerid] = true;
    }
    else SendClientMessage(playerid,COLOR_LIGHTBLUE,"You must be at the cp to do that!");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)