[SOLVED \o/]sscanf and multiple optional parameters
#22

The plugin has lots of documentation http://forum.sa-mp.com/index.php?topic=145539.0.

For your command I think it would be something like this (untested sorry):
pawn Код:
CMD:v(playerid, params[])
{
    if(PlayerInfo[playerid][Level] < 3 && !IsPlayerAdmin(playerid)) return 0;

    new vname[32], colour1, colour2;
    if(unformat(params, "s[32]I(-1)I(-1)", vname, colour1, colour2)) {
        SendClientMessage(playerid, 0xFF0000FF, "USAGE: /v [ModelID/Name] (Colour 1) (Colour 2)");
        return 1;
    }

    new modelid = strval(vname);
    if(modelid > 611 || modelid < 400) {
        modelid = GetVehicleModelIDFromName(vname);
        if(modelid == INVALID_MODEL_ID) {   // whatever GetVehicleModelIDFromName returns when no model is found
            SendClientMessage(playerid, 0xFF0000FF, "Invalid Vehicle Model");
            return 1;
        }
    }

    new Float:px, Float:py, Float:pz, Float:prot;
    if(IsPlayerInAnyVehicle(playerid)) {
        GetVehiclePos(GetPlayerVehicleID(playerid), px, py, pz);
        GetVehicleZAngle(GetPlayerVehicleID(playerid), prot);
    } else {
        GetPlayerPos(playerid, px, py, pz);
        GetPlayerFacingAngle(playerid, prot);
    }

    new vid = CreateVehicle(modelid, px + 4*floatcos(prot + 90.0, degrees), py + 4*floatsin(prot + 90.0, degrees), pz, prot + 90, colour1, colour2, -1);
    if(vid == INVALID_VEHICLE_ID) {
        SendClientMessage(playerid, 0xFF0000FF, "Vehicle limit reached");
        return 1;
    }
    if(vid >= sizeof(DynamicV)) {
        SendClientMessage(playerid, 0xFF0000FF, "Unable to create vehicle");
        DestroyVehicle(vid);
        return 1;
    }
    LinkVehicleToInterior(vid, GetPlayerInterior(playerid));
    SetVehicleVirtualWorld(vid, GetPlayerVirtualWorld(playerid));
    DynamicV[vid] = 1;

    new string[128];
    format(string, sizeof(string), "%s successfully spawned. To destroy it, use /dc", GetVehicleName(vid));
    SendClientMessage(playerid, 0xFFFFFFFF, string);
    return 1;
}
Reply


Messages In This Thread
[SOLVED \o/]sscanf and multiple optional parameters - by dcmd_crash - 22.04.2010, 00:03
Re: sscanf and multiple optional parameters - by cessil - 22.04.2010, 04:34
Re: sscanf and multiple optional parameters - by dcmd_crash - 22.04.2010, 18:09
Re: sscanf and multiple optional parameters - by ¤Adas¤ - 22.04.2010, 18:23
Re: sscanf and multiple optional parameters - by dcmd_crash - 22.04.2010, 18:30
Re: sscanf and multiple optional parameters - by dcmd_crash - 23.04.2010, 14:33
Re: sscanf and multiple optional parameters - by woot - 23.04.2010, 17:04
Re: sscanf and multiple optional parameters - by dcmd_crash - 23.04.2010, 17:10
Re: sscanf and multiple optional parameters - by biltong - 23.04.2010, 17:31
Re: sscanf and multiple optional parameters - by Calgon - 23.04.2010, 17:39
Re: sscanf and multiple optional parameters - by dice7 - 23.04.2010, 17:40
Re: sscanf and multiple optional parameters - by dcmd_crash - 23.04.2010, 17:54
Re: sscanf and multiple optional parameters - by dcmd_crash - 24.04.2010, 21:31
Re: sscanf and multiple optional parameters - by woot - 24.04.2010, 21:41
Re: sscanf and multiple optional parameters - by dcmd_crash - 24.04.2010, 21:48
Re: sscanf and multiple optional parameters - by woot - 24.04.2010, 21:54
Re: sscanf and multiple optional parameters - by dcmd_crash - 24.04.2010, 22:10
Re: sscanf and multiple optional parameters - by biltong - 24.04.2010, 22:16
Re: sscanf and multiple optional parameters - by dcmd_crash - 24.04.2010, 22:25
Re: sscanf and multiple optional parameters - by Virtual1ty - 24.04.2010, 22:32
Re: sscanf and multiple optional parameters - by dcmd_crash - 24.04.2010, 23:20
Re: sscanf and multiple optional parameters - by Dabombber - 25.04.2010, 02:38
Re: sscanf and multiple optional parameters - by woot - 25.04.2010, 09:00
Re: sscanf and multiple optional parameters - by Dabombber - 25.04.2010, 11:32
Re: sscanf and multiple optional parameters - by dcmd_crash - 25.04.2010, 21:06
Re: sscanf and multiple optional parameters - by Dabombber - 25.04.2010, 23:34
Re: sscanf and multiple optional parameters - by dcmd_crash - 25.04.2010, 23:41
Re: sscanf and multiple optional parameters - by dcmd_crash - 25.04.2010, 23:51
Re: sscanf and multiple optional parameters - by Calgon - 26.04.2010, 00:32
Re: sscanf and multiple optional parameters - by dcmd_crash - 26.04.2010, 00:36

Forum Jump:


Users browsing this thread: 1 Guest(s)