[REP+++](SSCANF)Vehicle Spawn by ID/NAME - Problem! - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [REP+++](SSCANF)Vehicle Spawn by ID/NAME - Problem! (
/showthread.php?tid=564026)
[REP+++](SSCANF)Vehicle Spawn by ID/NAME - Problem! -
cnoopers - 18.02.2015
Sooooo
spawning by name doesn't works.
WHY?!
Код:
CMD:v(playerid, params[])
{
new id;
new car;
new Vehicle[32], VehicleID;
new Float:x, Float:y;
new Float:x2, Float:y2, Float:z;
new worldid = GetPlayerVirtualWorld(playerid);
if(sscanf(params, "d", id)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /v [ID/name]");
if(id > 611 || id < 400)
{
return SendClientMessage(playerid, COLOR_GREY,"Error: Bad ID or name.");
}
else
{
GetXYInFrontOfPlayer(playerid, x, y, 5.0);
GetPlayerPos(playerid, x2, y2, z);
car = CreateVehicle(id, x, y, z, 0.0, 255, 255, -1);
SetVehicleVirtualWorld(car, worldid);
}
if(sscanf(params, "s[32]", Vehicle)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /v [ID/name]");
{
VehicleID = GetVehicleModelIDFromName(Vehicle);
GetXYInFrontOfPlayer(playerid, x, y, 5.0);
GetPlayerPos(playerid, x2, y2, z);
VehicleID = CreateVehicle(VehicleID, x, y, z, 0.0, 255, 255, -1);
SetVehicleVirtualWorld(VehicleID, worldid);
}
return 1;
}
Re: [REP+++](SSCANF)Vehicle Spawn by ID/NAME - Problem! -
Jefff - 18.02.2015
pawn Код:
CMD:v(playerid, params[])
{
if(isnull(params) || strlen(params) > 9) SendClientMessage(playerid, COLOR_GREY, "Usage: /v [ID/name]");
else
{
VehicleID = GetVehicleModelIDFromName(params);
if(!(400 <= VehicleID <= 611))
VehicleID = strval(params);
if(!(400 <= VehicleID <= 611)) SendClientMessage(playerid, COLOR_GREY,"Error: Bad ID or name.");
else{
new Float:x,Float:y,Floatz:
GetPlayerPos(playerid, x, y, z);
GetXYInFrontOfPlayer(playerid, x, y, 5.0);
VehicleID = CreateVehicle(VehicleID, x, y, z, 0.0, 255, 255, -1);
SetVehicleVirtualWorld(VehicleID, GetPlayerVirtualWorld(playerid));
}
}
return 1;
}
Re: [REP+++](SSCANF)Vehicle Spawn by ID/NAME - Problem! -
Djole1337 - 19.02.2015
You don't even need that function.
pawn Код:
if (sscanf(params, "k<vehicle>", vehicleid)) { // syntax } else { Spawn car vehicleid }
Re: [REP+++](SSCANF)Vehicle Spawn by ID/NAME - Problem! -
cnoopers - 19.02.2015
thanks!