SA-MP Forums Archive
SERVER Unkown commad. - 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: SERVER Unkown commad. (/showthread.php?tid=627523)



SERVER Unkown commad. - DerickClark - 29.01.2017

Код:
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;
}



Re: SERVER Unkown commad. - TYDS - 29.01.2017

change return 0; to return 1;


Re: SERVER Unkown commad. - DerickClark - 29.01.2017

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;
}



Re: SERVER Unkown commad. - Unte99 - 29.01.2017

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.


Re: SERVER Unkown commad. - DerickClark - 29.01.2017

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


Re: SERVER Unkown commad. - Hansrutger - 29.01.2017

Код:
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.


Re: SERVER Unkown commad. - DerickClark - 29.01.2017

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;
}



Re: SERVER Unkown commad. - Unte99 - 29.01.2017

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


Re: SERVER Unkown commad. - DerickClark - 29.01.2017

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.


Re: SERVER Unkown commad. - AndreiWow - 29.01.2017

Код:
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?