/getcar command
#1

I hate to ask for help, but I am really stuck.
I had the idea to make a /getcar command. So that it would be possible to call any car from antwhere to your location.
I got this far:

Код:
	if(strcmp(cmd, "/getcar", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /getcar [carid]");
				return 1;
			}
			if (PlayerInfo[playerid][pAdmin] >= 3)
			{
		    new Float:plocx,Float:plocy,Float:plocz;
	      GetPlayerPos(playerid, plocx, plocy, plocz);
				SetVehiclePos(CarID[playerid],plocx,plocy+4, plocz);
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "  you are not authorized to use that command!");
			}
		}
		return 1;
	}
But when I test this, nothing happens!
ps, maybe it's usefull information that I based this command on the /callcar command from GF.

Thanks for helping!
Reply
#2

SetVehiclePos is bugged. If nobody entered requested vehicle since it's respawn SetVehiclePos won't work on it.
You can avoid this with DestroyVehicle and CreateVehicle.
Reply
#3

There's also the slight issue that you don't actually create a vehicle... That's usually fairly important with a vehicle spawn script..

Never mind, misinterpreted.
Reply
#4

GetVehicleModelID to check if is valid vecid
GetPlayerPos to store player location
PutPlayerInVehicle to active vehicle
SetVehiclePos to tele vehicle
SetPlayerPos to remove player from vehicle
Reply
#5

Thanks for the reply's, I think they can help me.

#run into another problem I started working on the tip frp, Yezizhu. but PutPlayerInVehicle places the player on the passengers seet instead of the drivers position. The problem is that the car isn't activated by sitting on the passengers seet.
Reply
#6

https://sampwiki.blast.hk/wiki/PutPlayerInVehicle

Make sure to put him into seatid 0.

-> (0-driver, 1-co-driver, 2&3-passengers, if the car has enough seats
Reply
#7

Quote:
Originally Posted by //exora
https://sampwiki.blast.hk/wiki/PutPlayerInVehicle

Make sure to put him into seatid 0.

-> (0-driver, 1-co-driver, 2&3-passengers, if the car has enough seats
What he said I wanna say^^
Reply
#8

enter the car then run down the road and then try it it will work.
Reply
#9

Thanks again for all the help, I'm going to try again and I wll keep you up to date

#And yet again I am stuck
Код:
if(strcmp(cmd, "/getcar", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /getcar [carid]");
				return 1;
			}
			new testcar = strval(tmp);
			if (PlayerInfo[playerid][pAdmin] >= 3)
			{
				new Float:plocx,Float:plocy,Float:plocz;
	      GetPlayerPos(playerid, plocx, plocy, plocz);
				PutPlayerInVehicle(playerid, testcar, 0);
				SendClientMessage(playerid, COLOR_GRAD1, "  You have been teleported");
				SetVehiclePos (vehicleid, plocx, plocy, plocz);
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "  you are not authorized to use that command!");
			}
		}
		return 1;
	}
Tried what you all said, but I can't get it to work. If anyone got some spare time I would appriciate if you could look into this.
Thanks again.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)