28.08.2011, 18:08
Hello again and as usually I turn to the problem. So, I've in a map command named /V < Car Name > which looks like this:
function GetVehicleModelIDFromName:
When I'm trying to create car with license plate named "Name of server", then this command teleport me at front of docks in Las Venturas... Where is problem with this command? Thank in advance for help.
pawn Код:
CMD:v(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid, -1, "You must exit from THIS vehicle to create next car!");
int
name[20],
sCar,
CarID,
Float:V_X,
Float:V_Y,
Float:V_Z,
Float:V_Ang,
Int;
if(sscanf(params, "s[20]", name))
return SendClientMessage(playerid, Blue, "Wrong car name!");
sCar = GetVehicleModelIDFromName(name);
if(sCar < 400 || sCar > 611)
return SendClientMessage(playerid, Blue, ""#CRED"Use: "#CORANGE"/V < Car Name >");
if(sCar == 425 || sCar == 432 || sCar == 447 || sCar == 520 && !IsPlayerAdmin(playerid))
return SendClientMessage(playerid, Blue, "You can't create this vehicle, because you're not an administrator!");
int vehicleid;
SetVehicleToRespawn(vehicleid);
GetPlayerPos(playerid,V_X, V_Y, V_Z);
GetPlayerFacingAngle(playerid, V_Ang);
Int = GetPlayerInterior(playerid);
CarID = SetPVarInt(playerid, "VehicleSpawn", SetVehicleNumberPlate(CreateVehicle(sCar, V_X, V_Y, V_Z, V_Ang, -1, -1, -1), "Name of server"));
SetVehicleVirtualWorld(CarID, GetPlayerVirtualWorld(playerid));
PutPlayerInVehicle(playerid, CarID, 0);
LinkVehicleToInterior(CarID, Int);
int u_Message[128];
format(u_Message, sizeof(u_Message), ""#CORANGE"You create: "#CBLUE"%s", VehicleNames[sCar - 400]);
SendClientMessage(playerid, -1, u_Message);
return 1;
}
pawn Код:
stock GetVehicleModelIDFromName(vname[])
{
for(int i = 0; i < 211; i++)
{
if(strfind(VehicleNames[i], vname, true) != -1)
return i + 400;
}
return -1;
}