25.07.2016, 17:47
PHP код:
stock GetModelVehicle(vname[])
{
for(new i = 0; i < 211; i++)
{
if(strfind(VehicleNames[i], vname, true) != -1)
return i + 400;
}
return false;
}
CMD:vcreate(playerid, params[])
{
new vname[30];
if(sscanf(params, "s[30]", vname))
return SendClientMessage(playerid, COLOR_WHITE, "{ff0000}[Error]:{ffffff} /vcreate [vehicle name]");
else if(IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid, 0xFF0000FF, "{ff0000}[Error]:{ffffff} You are already in a vehicle.");
new model = GetModelVehicle(vname);
if(model < 400 || model > 611) return SendClientMessage(playerid, -1, "{ff0000}[Error]:{ffffff} /vcreate [vehicle name]");
new Float:x,Float:y,Float:z,Float:r,Float:nX,Float:nY,Float:nZ;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid,r);
x += (3.0 * floatsin(-r, degrees));
y += (3.0 * floatcos(-r, degrees));
new vehicleid = CreateVehicle(model, x, y, z+1.0, r+90, -1, -1, 5000);
SetVehicleVirtualWorld(vehicleid, GetPlayerVirtualWorld(playerid));
LinkVehicleToInterior(vehicleid, GetPlayerInterior(playerid));
new tmpstr[100];
format(tmpstr, sizeof(tmpstr), "You have spawned a %s.", GetVehicleName(vehicleid));
return SendClientMessage(playerid, COLOR_WHITE, tmpstr);
}