[REP+++](SSCANF)Vehicle Spawn by ID/NAME - Problem!
#1

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;
}
Reply
#2

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;
}
Reply
#3

You don't even need that function.

pawn Код:
if (sscanf(params, "k<vehicle>", vehicleid)) { // syntax } else { Spawn car vehicleid }
Reply
#4

thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)