Quote:
Originally Posted by Koala818
I found it way more simpler to create a function that verifies if a car is an IceCreamCar since you don't loop trough all vehicles, but just trough all the IceCream Vehicles. Simply, you verify if any of the IceCream car has the same id with the car that the player is in. If you find at least 1 you return 1(true) if not, you return 0. This way you don't use break or continue since "return" stops the execution of the function.
Anyway, if you'd like to read about this you can do it here https://sampwiki.blast.hk/wiki/Control_Structures#break
pawn Код:
//Icecream man CMD:sellicecream(playerid, params[]) { if(pInfo[playerid][pJobID] !=3) return SCM(playerid,COLOR_GREY, "[ERROR]: You must be an Icecream Man to sell ice cream."); if(IsPlayerInAnyVehicle(playerid)) { if(!IsAnIceCreamCar(GetPlayerVehicleID)) return SCM(playerid,COLOR_GREY, "[ERROR]: You must be in an Icecream Car to sell ice cream."); } else return SCM(playerid,COLOR_GREY, "[ERROR]: You must be in an Icecream Car to sell ice cream."); if(sscanf(params, "ud", target, price)) return SCM(pid,COLOR_WHITE, "USAGE: /sellicecream [playerid] [price 2-25$]"); if(price > 25 || price < 2) return SCM(pid,COLOR_GREY, "[ERROR]: Prices out of range. (2-25$)"); if(target == INVALID_PLAYER_ID) return SCM(pid,COLOR_GREY, "[ERROR]: playerid is not connected to the server."); return 1; } forward IsAnIceCreamCar(carid); public IsAnIceCreamCar(carid) { for(new k=0; k<MAX_ICECREAMCARS; k++) { if(carid==IceCreamJobVehicle[k]) return 1; } return 0; }
|
Slowly walking away and akwardly leaving cuz my post hasn't been seen.
P.S: That won't work for sure because you verify if the PlayerVehicleId==IceCreamJobVehicle[0]. If not, you stop the execution by returning 1.