need help with sscanf(params
#1

pawn Код:
CMD:aveh(playerid, params[])
{
    new Float:X, Float:Y, Float:Z, Float:Angle,veh[50],string[256],color1,color2;
    if(pInfo[playerid][Adminlevel] < 1) return SCM(playerid, COLOR_ERROR, ""ERROR_MESSAGE"");
    if(!pInfo[playerid][LoggedInAsAdmin]) return SCM(playerid,COLOR_ERROR,""ERROR_MESSAGE"");
    if(sscanf(params,"s[50]",veh)) return SCM(playerid, COLOR_ERROR, "USAGE: /aveh (Vehicle Name) (Color) (Color)");
    new vehicle = GetVehicleModelIDFromName(veh);
    if(vehicle < 400 || vehicle > 611) return SCM(playerid, COLOR_ERROR, ">> Invalid Vehicle Name.");
    if(IsPlayerInAnyVehicle(playerid)) return  SCM(playerid,COLOR_ERROR,">> You Are Already In A Vehicle.");
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerFacingAngle(playerid, Angle);
    PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
    format(string, sizeof(string), ">> You have spawned a %s. ID: %i. with color %d - %d ", VehicleNames[vehicle - 400], vehicle,color1,color2);
    SCM(playerid, COLOR_SKYBLUE, string);
    if(!sscanf(params,"s[50]dd",veh,color1,color2))
    {
        cVeh = CreateVehicle(vehicle, X+5, Y, Z, Angle, color1, color2, 1200);
    }
    if(!sscanf(params,"s",veh))
    {
        cVeh = CreateVehicle(vehicle, X+5, Y, Z, Angle, 0, 0, 1200);
    }
    PutPlayerInVehicle(playerid,cVeh,0);
    LinkVehicleToInterior(cVeh, GetPlayerInterior(playerid));
    SetVehicleVirtualWorld(cVeh, GetPlayerVirtualWorld(playerid));
    return 1;
}
CMD:veh(playerid, params[])
{
    new Vehicle[50], color1, color2,string[128], angle,Float:X, Float:Y, Float:Z,PVeh;
    if(pInfo[playerid][Adminlevel] < 1) return SCM(playerid, COLOR_ERROR, ""ERROR_MESSAGE"");
    if(!pInfo[playerid][LoggedInAsAdmin]) return SCM(playerid,COLOR_ERROR,""ERROR_MESSAGE"");
    if(sscanf(params, "s[50]", Vehicle, color1, color2)) return SCM(playerid, COLOR_ERROR, "USAGE: /veh (Vehicle Name) (color) (color)");
    new veh = GetVehicleModelIDFromName(Vehicle);
    if(veh < 400 || veh > 611) return SCM(playerid, COLOR_ERROR, "Invalid Vehicle ID / Name.");
    GetPlayerPos(playerid, X, Y, Z);
    if(!sscanf(params,"s[50]dd",veh,color1,color2))
    {
        PVeh = CreateVehicle(veh, X+3, Y, Z, angle, color1, color2, -1);
    }
    if(!sscanf(params,"s",veh))
    {
        PVeh = CreateVehicle(veh, X+3, Y, Z, angle, -1, -1, -1);
    }
    LinkVehicleToInterior(PVeh, GetPlayerInterior(playerid));
    SetVehicleVirtualWorld(PVeh, GetPlayerVirtualWorld(playerid));
    format(string, sizeof(string), ">> You have spawned a %s. ID: %i with color %d - %d", VehicleNames[veh - 400], veh,color1,color2);
    SCM(playerid, COLOR_SKYBLUE, string);
    ChangeVehicleColor(PVeh, color1, color2);
    return 1;
}
these command won't work fine
if i use /aveh bullet 0 1
it says invalid vehicle name
if i use /veh bullet
it returns ERROR_MESSAGE
if i use /veh bullet 0 1
it says invalid vehicle name or id
Reply


Messages In This Thread
need help with sscanf(params - by AroseKhanNiazi - 19.07.2014, 23:33
Re: need help with sscanf(params - by sammp - 19.07.2014, 23:40
Re: need help with sscanf(params - by AroseKhanNiazi - 19.07.2014, 23:46
Re: need help with sscanf(params - by TheKillZone - 20.07.2014, 00:21
Re: need help with sscanf(params - by AroseKhanNiazi - 20.07.2014, 00:30
Re: need help with sscanf(params - by AroseKhanNiazi - 20.07.2014, 14:51
Re: need help with sscanf(params - by MehranGta - 20.07.2014, 17:10
Re: need help with sscanf(params - by AroseKhanNiazi - 20.07.2014, 17:28

Forum Jump:


Users browsing this thread: 1 Guest(s)