/goto whit vehicle
#1

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.
Reply
#2

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.
Reply
#3

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.
Reply
#4

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


Forum Jump:


Users browsing this thread: 1 Guest(s)