Help with code, why do i get these errors?
#1

Hi i am trying to code it so that when the player enters into the checkpoint it first-

checks to see whether he is in a vehicle-if not it deletes the checkpoint.

if he is in vehicle i need to check whether trailer is attached..

Hopefully you can see what i am trying to do by my code.

Код:
public OnPlayerEnterCheckpoint(playerid) {

new vehicleid=GetPlayerVehicleID( playerid );
if (IsPlayerInVehicle(playerid,vehicleid) ) {

if ( IsTrailerAttachedToVehicle(vehicleid) );
 {
SendClientMessage( playerid, 0xAFAFAFAA, " Congratulations!" );
GivePlayerMoney(playerid, 5000);
DisablePlayerCheckpoint(playerid);
}
else {
SendClientMessage( playerid, 0xAFAFAFAA, "You need a trailer." );
}}

else { DisablePlayerCheckpoint(playerid);
}

return 1;
}
i get two errors when i compile this.

: error 029: invalid expression, assumed zero
: error 036: empty statement

Thanks in advance,
josh

Reply
#2

if ( IsTrailerAttachedToVehicle(vehicleid) );
Reply
#3

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
    new vehicleid = GetPlayerVehicleID(playerid);
    if(IsPlayerInVehicle(playerid,vehicleid))
    {
        if(IsTrailerAttachedToVehicle(vehicleid))
        {
            SendClientMessage(playerid, 0xAFAFAFAA, "Congratulations!");
            GivePlayerMoney(playerid, 5000);
            DisablePlayerCheckpoint(playerid);
        }
        else
        {
            SendClientMessage(playerid, 0xAFAFAFAA, "You need a trailer.");
        }
    }
    else
    {
        DisablePlayerCheckpoint(playerid);
    }
    return 1;
}
it compiles for me with no errors
Reply
#4

Try this:

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
    new vehicleid = GetPlayerVehicleID(playerid);
    if(IsPlayerInVehicle(playerid,vehicleid) && IsTrailerAttachedToVehicle(vehicleid))
    {

            SendClientMessage(playerid, 0xAFAFAFAA, "Congratulations!");
            GivePlayerMoney(playerid, 5000);
            DisablePlayerCheckpoint(playerid);
    }
    else
    {
            SendClientMessage(playerid, 0xAFAFAFAA, "You need a trailer.");
            DisablePlayerCheckpoint(playerid);
    }
    return 1;
}
This way the player has to be in the specified vehicle AND have the trailer attached.

Compiles with no errors
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)