SA-MP Forums Archive
strcmp problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: strcmp problem (/showthread.php?tid=402410)



strcmp problem - MattSlater - 26.12.2012

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


Re: strcmp problem - Faisal_khan - 26.12.2012

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.


Re: strcmp problem - MattSlater - 26.12.2012

It print's it


Re: strcmp problem - Faisal_khan - 26.12.2012

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


Re: strcmp problem - MattSlater - 26.12.2012

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


Re: strcmp problem - Faisal_khan - 26.12.2012

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



Re: strcmp problem - MattSlater - 26.12.2012

didn't work


Re: strcmp problem - RedCrossER - 26.12.2012

It doesn't show any game text also?


Re: strcmp problem - tyler12 - 26.12.2012

Getting the vehicleid might help.


Re: strcmp problem - RedCrossER - 26.12.2012

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