10.05.2016, 12:27
(
Последний раз редактировалось Dayrion; 10.05.2016 в 13:03.
)
Have you already a command which spawn cars like Eymeric69 wrote ?
For a newbie pawner, create a command which is saving and loading vehicle's parameter is hard.
Try to create a simple command like this (create a vehicle at the player's coordinates by typing /v) :
First way (for, it's the best way):
Second way:
I hope this helped you. The both command might work. If not, say it to me.
For a newbie pawner, create a command which is saving and loading vehicle's parameter is hard.
Try to create a simple command like this (create a vehicle at the player's coordinates by typing /v) :
First way (for, it's the best way):
PHP код:
#include <a_samp>
#include <ssanf>
#include <zcmd>
#define COLOR_RED 0xff0000FF // We define COLOR_RED as an hexadecimal color (red)
#define COLOR_GREEN 0x33cc33FF // We define COLOR_GREEN as an hexadecimal color (green)
CMD:v(playerid, params[])
{
new model, Float:x, Float:y, Float:z, Float:angle, vehicleid;
/* 6 variables : 4 for the player's coordinates (x, y, z, angle) and 1 for the model of the vehicle and 1 for the vehicle's ID (/!\ Model =/= ID /!\)
model is an Integer (https://en.wikipedia.org/wiki/Integer) and x, y, z and angle are float values (https://www.techopedia.com/definition/23980/float) */
if(sscanf(params, "i", model)) return SendClientMessage(playerid, COLOR_GREEN, "/v [model_id] [400-611]");
/*If the parameter 'model' isn't define by the player (ex: he type /v), we send to him a message to make him know what he should do.
The model to be between 400-611 (Check : https://sampwiki.blast.hk/wiki/Vehicle_Model_ID_List) */
if(611 > model || model < 400) return SendClientMessage(playerid, COLOR_RED, "[SYSTEM] Invalid ID [400-611]");
/* If the model isn't between 400-611 (ex: /v 99999, send to the player an error message) - '||' mean OR. */
GetPlayerPos(playerid, x, y, z);
/* We store the player's coordinates into differents variables (x, y, z) */
GetPlayerFacingAngle(playerid, angle);
/* We stock the facing angle in the variable Angle*/
vehicleid = CreateVehicle(model, x, y, z, angle, -1, -1, 10000);
/* CreateVehicle(modelOfTheVehicle, Coordinate x, Coordinate y, Coordinate z, rotation of the vehicle, Primary color (-1 is random), Secondary color (-1 is random), respawn delay (in ms));
Check this : https://sampwiki.blast.hk/wiki/CreateVehicle */
PutPlayerInVehicle(playerid, vehicleid, 0);
/*We put the player in the vehicle at the seat 0. Why?
There is different seat :
0 - Driver
1 - Front passenger
2 - Back-left passenger
3 - Back-right passenger
4+ - Passenger seats (coach etc.) */
SendClientMessage(playerid, COLOR_GREEN, "You have been teleported!"); // We send a basic message to say the player has been teleported
return 1; // Return 1 to terminate the command
}
PHP код:
#define COLOR_RED 0xff0000FF // We define COLOR_RED as an hexadecimal color (red)
#define COLOR_GREEN 0x33cc33FF // We define COLOR_GREEN as an hexadecimal color (green)
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128], idx;
cmd = strtok(cmdtext, idx);
if (strcmp(cmd, "/v", true) == 0) // If the player type /tp than we executes those following lines
{
new Float:x, Float:y, Float:z, Float:angle, tmp[128], vehicleid;
/* 6 variables : 4 for the player's coordinates (x, y, z, angle), 1 for the model of the vehicle and 1 for the vehicle's ID.
model is an Integer (https://en.wikipedia.org/wiki/Integer) and x, y, z and angle are float values (https://www.techopedia.com/definition/23980/float) */
tmp = strtok(cmdtext, idx);
if(strlen(tmp) == 0) return SendClientMessage(playerid, COLOR_GREEN, "/v [model_id] [400-611]");
/*If the player have just typed /v without parameter return an error message*/
if(611 > model || model < 400) return SendClientMessage(playerid, COLOR_RED, "[SYSTEM] Invalid ID [400-611]");
/* If the model isn't between 400-611 (ex: /v 99999, send to the player an error message) - '||' mean OR. */
GetPlayerPos(playerid, x, y, z);
/* We stock the position in differents variables (x, y, z) */
GetPlayerFacingAngle(playerid, angle);
/* We stock the facing angle in the variable Angle*/
new vehicleid = CreateVehicle(strval(temp)), x, y, z, angle, -1, -1, 1000);
/* strval(value) : convert a string to an integer
CreateVehicle(modelOfTheVehicle, Coordinate x, Coordinate y, Coordinate z, rotation of the vehicle, Primary color (-1 is random), Secondary color (-1 is random), respawn delay (in ms));
Link can be fin here : https://sampwiki.blast.hk/wiki/Vehicle_M...4.02649537
We create the vehicle at the player's coordinate */
PutPlayerInVehicle(playerid, vehicleid, 0);
/*We put the player in the vehicle at the seat 0. Why? Seat 0 = driver
0 - Driver
1 - Front passenger
2 - Back-left passenger
3 - Back-right passenger
4+ - Passenger seats (coach etc.)*/
SendClientMessage(playerid, COLOR_GREEN, "You have spawned an vehicle!"); // We send a basic message to say the player has been teleported
return 1;
}
return 0;
}