SERVER Unkown commad.
#1

Код:
CMD:deleteveh(playerid,params[])
{
    if(!IsPlayerInAnyVehicle(playerid)) SendClientMessage(playerid, -1, "You need to be in a vehicle to use this command");
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        DestroyVehicle(vehicleid);
        SendClientMessage(playerid, COLOUR_RED,"You have removed this vehicle");
    }
    return 0;
}
Reply
#2

change return 0; to return 1;
Reply
#3

Quote:
Originally Posted by TYDS
Посмотреть сообщение
change return 0; to return 1;
Код:
(1623) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
@TYDS, now it's saying both messages



but i added like this
Код:
CMD:deleteveh(playerid,params[])
{
    if(!IsPlayerInAnyVehicle(playerid)) SendClientMessage(playerid, -1, "You need to be in a vehicle to use this command"); return 0;
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        DestroyVehicle(vehicleid);
        SendClientMessage(playerid, COLOUR_RED,"You have removed this vehicle");
    }
    return 1;
}
Reply
#4

Your if statement is wrong. You are checking if the player is in no vehicle, then in the same line send the message and then open a block for the if statement again for code to write... You can't do that as far as I know.
Reply
#5

Quote:
Originally Posted by DerickClark
Посмотреть сообщение
Код:
(1623) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
@TYDS, now it's saying both messages



but i added like this
Код:
CMD:deleteveh(playerid,params[])
{
    if(!IsPlayerInAnyVehicle(playerid)) SendClientMessage(playerid, -1, "You need to be in a vehicle to use this command"); return 0;
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        DestroyVehicle(vehicleid);
        SendClientMessage(playerid, COLOUR_RED,"You have removed this vehicle");
    }
    return 1;
}
How can i make the command. You have to be in the vehicle to remove this vehicle
Reply
#6

Код:
CMD:deleteveh(playerid,params[])
{
    if(!IsPlayerInAnyVehicle(playerid)) SendClientMessage(playerid, -1, "You need to be in a vehicle to use this command"); return 0; // Never do this if you plan to...
    { // ... create brackets here...
        new vehicleid = GetPlayerVehicleID(playerid);
        DestroyVehicle(vehicleid);
        SendClientMessage(playerid, COLOUR_RED,"You have removed this vehicle");
    } // ... and here
    return 1;
}
Remove the {}-brackets and you should be fine and remove the return 0, place "return" before SendClientMessage after the if-statement instead.
Reply
#7

When i removed the vehicle this pop up

SendClientMessage(playerid, COLOUR_RED,"You removed vehicle");
SERVER: Unkown commad.
Код:
CMD:deleteveh(playerid,params[])
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You need to be in a vehicle to use this command");
    {
        SendClientMessage(playerid, COLOUR_RED,"You removed vehicle");
        new vehicleid = GetPlayerVehicleID(playerid);
        DestroyVehicle(vehicleid);
    }
    return 0;
}
Reply
#8

Quote:
Originally Posted by DerickClark
Посмотреть сообщение
How can i make the command. You have to be in the vehicle to remove this vehicle
Check this and you will know how to do this:

https://sampwiki.blast.hk/wiki/Control_Structures#else
Reply
#9

Quote:
Originally Posted by Unte99
Посмотреть сообщение
Check this and you will know how to do this:

https://sampwiki.blast.hk/wiki/Control_Structures#else
edited post above you.
Reply
#10

Код:
CMD:deleteveh(playerid,params[])
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        DestroyVehicle(vehicleid);
        SendClientMessage(playerid, COLOUR_RED,"You have removed this vehicle");
    }
    else
    {
     SendClientMessage(playerid, -1, "Your text.");
     }
    return 1;
}
Try this?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)