Neon Problem
#3

Try this, I added a bool:
pawn Код:
if(strcmp(cmd,"/neon",true)==0)
                    {
                        if(IsPlayerConnected(playerid))
                        {
                            new x_job[64], bool: color[MAX_PLAYERS];
                            x_job = strtok(cmdtext, idx);
                            if(!strlen(x_job))
                            {
                                SendClientMessage(playerid, COLOR_WHITE, "|__________________ Neon __________________|");
                                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /neon [name]");
                                SendClientMessage(playerid, COLOR_GREY, "Available names: Red, Blue, Yellow, White, Pink, Green, Takeoff");
                                SendClientMessage(playerid, COLOR_WHITE, "|____________________________________________|");
                                return 1;
                            }
                            else
                            {
                                if(strcmp(x_job,"red",true) == 0)
                                {
                                    if(Neon[playerid] < 0){return 1;}
                                    SetPVarInt(playerid, "neon", 1);
                                    SetPVarInt(playerid, "red", CreateObject(18647,0,0,0,0,0,0));
                                    SetPVarInt(playerid, "red1", CreateObject(18647,0,0,0,0,0,0));
                                    AttachObjectToVehicle(GetPVarInt(playerid, "red"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
                                    AttachObjectToVehicle(GetPVarInt(playerid, "red1"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
                                    GameTextForPlayer(playerid, "~r~Red ~w~Neon has been added to your vehicle",3500,5);
                                    color[playerid]=true;
                                }
                                else if(strcmp(x_job,"blue",true) == 0)
                                {
                                    if(Neon[playerid] < 0){return 1;}
                                    SetPVarInt(playerid, "neon", 1);
                                    SetPVarInt(playerid, "blue", CreateObject(18648,0,0,0,0,0,0));
                                    SetPVarInt(playerid, "blue1", CreateObject(18648,0,0,0,0,0,0));
                                    AttachObjectToVehicle(GetPVarInt(playerid, "blue"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
                                    AttachObjectToVehicle(GetPVarInt(playerid, "blue1"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
                                    GameTextForPlayer(playerid, "~b~ Blue ~w~Neon has been added to your vehicle",3500,5);
                                    color[playerid]=true;
                                }
                                else if(strcmp(x_job,"yellow",true) == 0)
                                {
                                    if(Neon[playerid] < 0){return 1;}
                                    SetPVarInt(playerid, "neon", 1);
                                    SetPVarInt(playerid, "yellow", CreateObject(18650,0,0,0,0,0,0));
                                    SetPVarInt(playerid, "yellow1", CreateObject(18650,0,0,0,0,0,0));
                                    AttachObjectToVehicle(GetPVarInt(playerid, "yellow"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
                                    AttachObjectToVehicle(GetPVarInt(playerid, "yellow1"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
                                    GameTextForPlayer(playerid, "~y~Yellow~w~ Neon has been added to your vehicle",3500,5);
                                    color[playerid]=true;
                                }
                                else if(strcmp(x_job,"white",true) == 0)
                                {
                                    if(Neon[playerid] < 0){return 1;}
                                    SetPVarInt(playerid, "neon", 1);
                                    SetPVarInt(playerid, "white", CreateObject(18652,0,0,0,0,0,0));
                                    SetPVarInt(playerid, "white1", CreateObject(18652,0,0,0,0,0,0));
                                    AttachObjectToVehicle(GetPVarInt(playerid, "white"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
                                    AttachObjectToVehicle(GetPVarInt(playerid, "white1"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
                                    GameTextForPlayer(playerid, "~w~White~w~ Neon has been added to your vehicle",3500,5);
                                    color[playerid]=true;
                                }
                                else if(strcmp(x_job,"pink",true) == 0)
                                {
                                    if(Neon[playerid] < 0){return 1;}
                                    SetPVarInt(playerid, "neon", 1);
                                    SetPVarInt(playerid, "pink", CreateObject(18651,0,0,0,0,0,0));
                                    SetPVarInt(playerid, "pink1", CreateObject(18651,0,0,0,0,0,0));
                                    AttachObjectToVehicle(GetPVarInt(playerid, "pink"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
                                    AttachObjectToVehicle(GetPVarInt(playerid, "pink1"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
                                    GameTextForPlayer(playerid, "~p~Pink~w~ Neon has been added to your vehicle",3500,5);
                                    color[playerid]=true;
                                }
                                else if(strcmp(x_job,"green",true) == 0)
                                {
                                    if(Neon[playerid] < 0){return 1;}
                                    SetPVarInt(playerid, "neon", 1);
                                    SetPVarInt(playerid, "green", CreateObject(18649,0,0,0,0,0,0));
                                    SetPVarInt(playerid, "green1", CreateObject(18649,0,0,0,0,0,0));
                                    AttachObjectToVehicle(GetPVarInt(playerid, "green"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
                                    AttachObjectToVehicle(GetPVarInt(playerid, "green1"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
                                    GameTextForPlayer(playerid, "~g~Green ~w~Neon has been added to your vehicle",3500,5);
                                    color[playerid]=true;
                                }
                                else if(strcmp(x_job,"takeoff",true) == 0)
                                {
                                    if (color[playerid]==true)
                                    {
                                    color[playerid]=false;
                                     DestroyObject(GetPVarInt(playerid, "blue"));
                                     DeletePVar(playerid, "neon");
                                    DestroyObject(GetPVarInt(playerid, "blue1"));
                                    DeletePVar(playerid, "neon");
                                    //
                                    DestroyObject(GetPVarInt(playerid, "red"));
                                    DeletePVar(playerid, "neon");
                                    DestroyObject(GetPVarInt(playerid, "red1"));
                                    DeletePVar(playerid, "neon");
                                    //
                                    DestroyObject(GetPVarInt(playerid, "green"));
                                    DeletePVar(playerid, "neon");
                                    DestroyObject(GetPVarInt(playerid, "green1"));
                                    DeletePVar(playerid, "neon");
                                    //
                                    DestroyObject(GetPVarInt(playerid, "yellow"));
                                    DeletePVar(playerid, "neon");
                                    DestroyObject(GetPVarInt(playerid, "yellow1"));
                                    DeletePVar(playerid, "neon");
                                    //
                                    DestroyObject(GetPVarInt(playerid, "white"));
                                    DeletePVar(playerid, "neon");
                                    DestroyObject(GetPVarInt(playerid, "white1"));
                                    DeletePVar(playerid, "neon");
                                    //
                                    DestroyObject(GetPVarInt(playerid, "pink"));
                                    DeletePVar(playerid, "neon");
                                    DestroyObject(GetPVarInt(playerid, "pink1"));
                                     DeletePVar(playerid, "neon");
                                    }
                                    else
                                    {
                                        SendClientMessage(playerid, 1, "{FF0000} You havent applied any neon color to your vehicle"
                                    }
                                }
                          }
                          return 1;
                    }
BUT Think about this: What if a player enables neon to a car, exits that car, enters another and tries to enable neon again? To prevent that unpleasant situation you have to turn the bool to false under "public OnPlayerExitVehicle" .

EDIT: oh damn i think this last one I say is crap, cause if he exits vehicle then he wont be able ever to apply neon egain. In order to prevent the above situation youve got to mess with vehicle ids.
Reply


Messages In This Thread
Neon Problem - by Akcent_Voltaj - 17.04.2013, 11:37
Re: Neon Problem - by DaRk_RaiN - 17.04.2013, 11:46
Re: Neon Problem - by HurtLocker - 17.04.2013, 11:54
Re: Neon Problem - by Akcent_Voltaj - 17.04.2013, 12:17
Re: Neon Problem - by Akcent_Voltaj - 17.04.2013, 13:05
Re: Neon Problem - by Akcent_Voltaj - 17.04.2013, 13:24
Re: Neon Problem - by kalanerik99 - 17.04.2013, 14:05
Re: Neon Problem - by Akcent_Voltaj - 17.04.2013, 14:57
Re: Neon Problem - by HurtLocker - 17.04.2013, 15:33
Re: Neon Problem - by Pottus - 17.04.2013, 15:35

Forum Jump:


Users browsing this thread: 1 Guest(s)