strcmp problem
#1

pawn Код:
CMD:v(playerid, params[])
{
    new engine, lights, alarm, doors, bonnet, boot, objective, string[96], vehicleid = GetPlayerVehicleID(playerid);
    GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to be inside a vehicle to use this command!");
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You need to be driving the vehicle to use this command!");
    if(isnull(params)) return SendClientMessage(playerid, COLOR_GREY, "[USAGE]: /v [hood/trunk/lights]");
    if(!isnull(params)) {
        if(!strcmp(params, "hood", true)) {
            if(bonnet == 0) {
                format(string, sizeof(string), "* %s has opened the hood.", GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, 1, boot, objective);
                GameTextForPlayer(playerid, "~g~VEHICLE HOOD OPENED!", 3000, 1);
            }
            else if(bonnet == 1) {
                format(string, sizeof(string), "* %s has closed the hood.", GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, 0, boot, objective);
                SendClientMessage(playerid, COLOR_LIGHTGREEN, "You have closed the hood! (/chood to open it)");
                GameTextForPlayer(playerid, "~w~VEHICLE HOOD CLOSED!", 3000, 1);
            }
        }
        if(!strcmp(params, "trunk", true)) {
            if(bonnet == 0) {
                format(string, sizeof(string), "* %s has opened the trunk.", GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, 1, objective);
                GameTextForPlayer(playerid, "~g~VEHICLE TRUNK CLOSED!", 3000, 1);
            }
            else if(bonnet == 1) {
                format(string, sizeof(string), "* %s has closed the trunk.", GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, 0, objective);
                GameTextForPlayer(playerid, "~w~VEHICLE TRUNK CLOSED!", 3000, 1);
            }
        }
        if(!strcmp(params, "lights", true)) {
            if(lights == 0) {
                format(string, sizeof(string), "* %s has turned on the vehicle lights.", GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(vehicleid, engine, 1, alarm, doors, bonnet, boot, objective);
                GameTextForPlayer(playerid, "~g~VEHICLE LIGHTS ON!", 3000, 1);
            }
            else if(lights == 1) {
                format(string, sizeof(string), "* %s has turned off the vehicle lights.", GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(vehicleid, engine, 0, alarm, doors, bonnet, boot, objective);
                GameTextForPlayer(playerid, "~w~VEHICLE LIGHTS OFF!", 3000, 1);
            }
        }
    }
    return 1;
}
Okay, basically

Nothing happens if I do for eg: /v lights

Any idea why
Reply
#2

Tell us if the console is printing "Its working pal!" when you are using the command.
pawn Код:
CMD:v(playerid, params[])
{
    print("Its working pal!");
    new engine, lights, alarm, doors, bonnet, boot, objective, string[96], vehicleid = GetPlayerVehicleID(playerid);
    GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to be inside a vehicle to use this command!");
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You need to be driving the vehicle to use this command!");
    if(isnull(params)) return SendClientMessage(playerid, COLOR_GREY, "[USAGE]: /v [hood/trunk/lights]");
    if(!isnull(params)) {
        if(!strcmp(params, "hood", true)) {
            if(bonnet == 0) {
                format(string, sizeof(string), "* %s has opened the hood.", GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, 1, boot, objective);
                GameTextForPlayer(playerid, "~g~VEHICLE HOOD OPENED!", 3000, 1);
            }
            else if(bonnet == 1) {
                format(string, sizeof(string), "* %s has closed the hood.", GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, 0, boot, objective);
                SendClientMessage(playerid, COLOR_LIGHTGREEN, "You have closed the hood! (/chood to open it)");
                GameTextForPlayer(playerid, "~w~VEHICLE HOOD CLOSED!", 3000, 1);
            }
        }
        if(!strcmp(params, "trunk", true)) {
            if(bonnet == 0) {
                format(string, sizeof(string), "* %s has opened the trunk.", GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, 1, objective);
                GameTextForPlayer(playerid, "~g~VEHICLE TRUNK CLOSED!", 3000, 1);
            }
            else if(bonnet == 1) {
                format(string, sizeof(string), "* %s has closed the trunk.", GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, 0, objective);
                GameTextForPlayer(playerid, "~w~VEHICLE TRUNK CLOSED!", 3000, 1);
            }
        }
        if(!strcmp(params, "lights", true)) {
            if(lights == 0) {
                format(string, sizeof(string), "* %s has turned on the vehicle lights.", GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(vehicleid, engine, 1, alarm, doors, bonnet, boot, objective);
                GameTextForPlayer(playerid, "~g~VEHICLE LIGHTS ON!", 3000, 1);
            }
            else if(lights == 1) {
                format(string, sizeof(string), "* %s has turned off the vehicle lights.", GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(vehicleid, engine, 0, alarm, doors, bonnet, boot, objective);
                GameTextForPlayer(playerid, "~w~VEHICLE LIGHTS OFF!", 3000, 1);
            }
        }
    }
    return 1;
}
P.S. Its not related to strcmp.
Reply
#3

It print's it
Reply
#4

Ok so your command works, now try it without entering in the car, then try it as a passenger and then try it without writing the params i.e. just /v
Reply
#5

just /v works its just when i do /v lights or something it doesnt
Reply
#6

Try changing this
pawn Код:
if(!strcmp(params, "hood", true))
to
pawn Код:
if(strcmp(params, "hood", true))
Reply
#7

didn't work
Reply
#8

It doesn't show any game text also?
Reply
#9

Getting the vehicleid might help.
Reply
#10

Well create a new value and assign vehicle I'd to it and use that value everywhere.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)