[dafuq] YCMD:Veh first returns 0, than returns 1 instead of formated string
#1

Hello, as I mentioned previously, my COMMAND /veh

first time I type
/veh 522 1 1 ( white NRG-500, or anything else)

it CREATES a vehicle, put me in vehicle, but returns 0 (COMMAND DOES NOT EXIST)
when i /Dtc (destroy this vehicle)
and than again type:

/veh 522 1 1 ( any model/color )

it CREATES a vehicle, put me in vehicle, Does NOT return 0, but it won't show me up string (in client message, formated previously ([A] > %s has crated vehicle blabla)

Dafuq, I have no idea what's wrong in this code, if anybody knows please Help me, I will rep(rape) you

P.S. Function SendAdminMessage works fine, that's not the problem



pawn Код:
YCMD:veh(playerid, params[], help)
{
    #pragma unused help
    new vehicle,col1,col2,string[128],Float:x,Float:y,Float:z,Float:a,crVeh;
    if(PlayerInfo[playerid][pAdmin] < 2)
        return SCM(playerid,COLOR_DARKRED,"[CA:RP]"gray" Admins only!");
    else if(sscanf(params, "iii", vehicle, col1,col2))
        return SCM(playerid, COLOR_GRAY,"Usage: /veh [model] [Color 1] [Color 2]");
    else if(vehicle< 400 || vehicle> 611)
        return SCM(playerid, COLOR_GRAY,"Wrong vehicle model (400-611)");

    GetPlayerPos(playerid,x,y,z);
    GetPlayerFacingAngle(playerid, a);
    crVeh = CreateVehicle(vehicle,x,y,z,a,col1,col2,-1);
    PutPlayerInVehicle(playerid, crVeh, 0);
    vehicleCreated[crVeh] = 1;
    SetVehicleNumberPlate(crVeh,"Admin Car");
    format(string, sizeof(string), " You have created vehicle | Model : %d | ID: %d | Model Name: %s", vehicle, crVeh, GetVehicleName(vehicle));
    SCM(playerid, COLOR_GRAY,string);
    format(string, sizeof(string), " [>>] [A] %s has created vehicle | ID = %d | Model = %d (%s)", PlayerName(playerid), crVeh, vehicle, GetVehicleName(vehicle));
    SendAdminMessage(1, COLOR_YELLOW, string);
    return 1;
}
Reply
#2

SendAdminMessage(1, COLOR_YELLOW, string);

What does the parameter 1 mean ?

Also...

pawn Код:
#pragma unused help
    new vehicle,col1,col2,string[128],Float:x,Float:y,Float:z,Float:a,crVeh;
    if(PlayerInfo[playerid][pAdmin] < 2)
        return SCM(playerid,COLOR_DARKRED,"[CA:RP]"gray" Admins only!");
    else if(sscanf(params, "iii", vehicle, col1,col2))
        return SCM(playerid, COLOR_GRAY,"Usage: /veh [model] [Color 1] [Color 2]");
    else if(vehicle< 400 || vehicle> 611)
        return SCM(playerid, COLOR_GRAY,"Wrong vehicle model (400-611)");

Should be

    #pragma unused help

    if(PlayerInfo[playerid][pAdmin] < 2) return SCM(playerid,COLOR_DARKRED,"[CA:RP]"gray" Admins only!");

    new vehicle,col1,col2;

    if(sscanf(params, "iii", vehicle, col1,col2)) return SCM(playerid, COLOR_GRAY,"Usage: /veh [model] [Color 1] [Color 2]");
    if(vehicle< 400 || vehicle> 611) return SCM(playerid, COLOR_GRAY,"Wrong vehicle model (400-611)");

    new string[128],Float:x,Float:y,Float:z,Float:a,crVeh;
There is no need to create variables until you need them, else if is not really needed since your going to check all these steps anyways just use if statements.

And if you really want to get technical do this

pawn Код:
#define CMDLEVEL(%0) if(PlayerInfo[playerid][pAdmin] < %0) return SCM(playerid,COLOR_DARKRED,"[CA:RP]"gray" Admins only!");
Then just use CMDLEVEL(2); or CMDLEVEL(4); whatever you like in any command to set the command level.

Then we get this

pawn Код:
#pragma unused help

    CMDLEVEL(2);

    new vehicle,col1,col2;
    if(sscanf(params, "iii", vehicle, col1,col2)) return SCM(playerid, COLOR_GRAY,"Usage: /veh [model] [Color 1] [Color 2]");
    if(vehicle< 400 || vehicle> 611) return SCM(playerid, COLOR_GRAY,"Wrong vehicle model (400-611)");

    new string[128],Float:x,Float:y,Float:z,Float:a,crVeh;
Doesn't that look pretty ?
Reply
#3

Thanks dude, that's really helpful, REP+

edit: param 1 means to send message to all admins which admin level equals or bigger than 1
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)