SA-MP Forums Archive
Commands & Vehicles - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Commands & Vehicles (/showthread.php?tid=210551)



Commands & Vehicles - Coffeemonster - 13.01.2011

Sup people.

I've got a very strange problem whilst scripting a gamemode, every command works whilst on foot, but when I enter a vehicle, teleport commands stop working. Even tough, commands like /rules and /help works in a vehicle also..I tried to move around and tweak the IsPlayerInVehicle checks in a teleport, but I still get UNKNOWN COMMAND error while typing a teleport inside a vehicle.

I've added these variables just right under OnPlayerCommandText:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	new vehicleid = GetPlayerVehicleID(playerid);
	new State = GetPlayerState(playerid);
And here is an example of a teleport:
Код:
        if (strcmp("/lv", cmdtext, true, 10) == 0)
	{
	SetPlayerInterior(playerid, 0);
	if(IsPlayerInAnyVehicle(playerid) && State == PLAYER_STATE_DRIVER)
	{
	GameTextForPlayer(playerid,"Las Venturas",4000,6);
	return SetVehiclePos(vehicleid,2039.5549,1625.7263,10.6719);
	}
	SetPlayerPos(playerid,2039.5549,1625.7263,10.6719);
	GameTextForPlayer(playerid,"Las Venturas",4000,6);
	return 1;
}



Re: Commands & Vehicles - __ - 13.01.2011

Create your variables in a more local scope (the if statement) for clarity, and make sure that you haven't added any redundant checks or have any broken commands (that retain missing curly brackets).


Re: Commands & Vehicles - Coffeemonster - 13.01.2011

Quote:
Originally Posted by __
Посмотреть сообщение
Create your variables in a more local scope (the if statement) for clarity, and make sure that you haven't added any redundant checks or have any broken commands (that retain missing curly brackets).
What do you mean by that? Could you give me an example of that? And I'll check the brackets.


Re: Commands & Vehicles - blackwave - 13.01.2011

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new vehicleid = GetPlayerVehicleID(playerid);
    new State = GetPlayerState(playerid);
         if (strcmp("/lv", cmdtext, true, 10) == 0)
    {
    if(IsPlayerInAnyVehicle(playerid) && State == PLAYER_STATE_DRIVER)
    {
    GameTextForPlayer(playerid,"Las Venturas",4000,6);
    SetPlayerInterior(playerid, 0);
        SetVehiclePos(vehicleid,2039.5549,1625.7263,10.6719);
    }

        else
{
    SetPlayerPos(playerid,2039.5549,1625.7263,10.6719);
    GameTextForPlayer(playerid,"Las Venturas",4000,6);
}
    return 1;
}
return 0;
}



Re: Commands & Vehicles - Coffeemonster - 13.01.2011

It's still unknown command with your method o.O.

EDIT: Fixed, problem was my animations.