SA-MP Forums Archive
/goto whit vehicle - 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: /goto whit vehicle (/showthread.php?tid=269555)



/goto whit vehicle - SamyRomafia - 16.07.2011

pawn Код:
CMD:goto( playerid, params[ ] )
{
   if(!cgoto[playerid]) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: This players don0t admit other players to teleport to him");
   if(playerinminigame[playerid] == 1) return Error(playerid);
   if( isnull( params ) ) return 0; // No player
   new targetid = strval( params );
   if( !IsPlayerConnected( targetid ) ) return 0; // Targeted player is not connected
   new Float: Pos[ 4 ];
   GetPlayerPos( targetid, Pos[ 0 ], Pos[ 1 ], Pos[ 2 ] );
   GetPlayerFacingAngle( targetid, Pos[ 3 ] );
   SetPlayerPos( playerid, Pos[ 0 ], Pos[ 1 ], Pos[ 2 ] );
   SetPlayerFacingAngle( playerid, Pos[ 3 ] );
   return 1;
}
In this goto command the player can't goto whit vehicle. How can i do whit vehicle.


Re: /goto whit vehicle - Lee_Percox - 16.07.2011

Check before setting the position if a player is in a vehicle.
use: https://sampwiki.blast.hk/wiki/Function:...erInAnyVehicle

If he is, then set the vehicle position with: https://sampwiki.blast.hk/wiki/SetVehiclePos

Simples.


Re: /goto whit vehicle - [MG]Dimi - 17.07.2011

And don't forget
PHP код:
PutPlayerInVehicle(playerid,vehicleid,seatid(0 id driver!)) 
so your code for TP will be

PHP код:
if(strcmp("/tp",cmdtext,true) == 0)
{
    
SetPlayerPos(playerid,x,y,z)
    if(
IsPlayerInAnyVehicle(playerid))
    {
        new 
vehid GetPlayerVehicleID(playerid);
        
SetVehiclePos(vehid,x,y,z);
        
PutPlayerInVehicle(playerid,vehid,0);
        return 
1;
    }
    return 
1;

This is just an example.


Re: /goto whit vehicle - Skaizo - 17.07.2011

Код:
CMD:goto(playerid, params[])
{
	 if(!strlen(params)) return
    	 SendClientMessage(playerid, LIGHTBLUE2, "Usage: /vgoto [VehicleID]")
         SendClientMessage(playerid, orange, "Function: Will Go to specified vehicle");
	 new player1;
         new string[128];
	 player1 = strval(params);
         SendCommandToAdmins(playerid,"VGoto");
	 new Float:x, Float:y, Float:z;
	 GetVehiclePos(player1,x,y,z);
	 SetPlayerVirtualWorld(playerid,GetVehicleVirtualWorld(player1));
	 if(GetPlayerState(playerid) == 2)
	 {
	      SetVehiclePos(GetPlayerVehicleID(playerid),x+3,y,z);
	      SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), GetVehicleVirtualWorld(player1));
	 }
	 else 
         {
               SetPlayerPos(playerid,x+2,y,z);
	       format(string,sizeof(string),"|- You have teleported to Vehicle ID: %d -|", player1);
	       return SendClientMessage(playerid,BlueMsg,string);
          }
          return 1;
}