/getcar command -
Rickk - 20.07.2009
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!
Re: /getcar command -
Sergei - 20.07.2009
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.
Re: /getcar command -
Weirdosport - 20.07.2009
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.
Re: /getcar command -
yezizhu - 20.07.2009
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
Re: /getcar command -
Rickk - 21.07.2009
Thanks for the reply's, I think they can help me.
#run into another problem
![Sad](images/smilies/sad.gif)
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.
Re: /getcar command -
woot - 21.07.2009
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
Re: /getcar command -
yezizhu - 21.07.2009
Quote:
Originally Posted by //exora
|
What he said I wanna say^^
Re: /getcar command -
[top_Shoter] - 21.07.2009
enter the car then run down the road and then try it it will work.
Re: /getcar command -
Rickk - 22.07.2009
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.