for(new i=0; i<sizeof(KraftstoffCars); i++) { if(vID == KraftstoffCars[i][kID]) { if(GetVehicleModel(GetVehicleTrailer(vID)) == 584) { tInfo[tID[playerid]][tFuelStand] = 100; SendClientMessage(playerid, COLOR_YELLOW, "You filled the gas pump."); GameTextForPlayer(playerid, "~g~PAYDAY +1500 $", 2000, 6); pInfo[playerid][payday] += 1500; return 1; } return SendClientMessage(playerid, COLOR_RED, "Your Truck doesn't have the right Trailer."); } return SendClientMessage(playerid, COLOR_RED, "You are not sitting in an Job-Truck"); }
Instead of putting the second message (and return) into the loop, you must move it outside of the loop, otherwise it will execute at the first iteration where the player is not in the correct truck (when you have for example 10 trucks, this might be the case for the first 9 iterations - this is why only the first truck works).
So only if the loop has finished completely and no truck was the one the player is driving, it should send the message saying the player isn't in any job truck. |
for(new i=0; i<sizeof(KraftstoffCars); i++) { if(vID == KraftstoffCars[i][kID]) { if(GetVehicleModel(GetVehicleTrailer(vID)) == 584) { tInfo[tID[playerid]][tFuelStand] = 100; SendClientMessage(playerid, COLOR_YELLOW, "You filled the gas pump."); GameTextForPlayer(playerid, "~g~PAYDAY +1500 $", 2000, 6); pInfo[playerid][payday] += 1500; return 1; } return SendClientMessage(playerid, COLOR_RED, "Your Truck doesn't have the right Trailer."); } } return SendClientMessage(playerid, COLOR_RED, "You are not sitting in an Job-Truck");
Code:
for(new i=0; i<sizeof(KraftstoffCars); i++) { if(vID == KraftstoffCars[i][kID]) { if(GetVehicleModel(GetVehicleTrailer(vID)) == 584) { tInfo[tID[playerid]][tFuelStand] = 100; SendClientMessage(playerid, COLOR_YELLOW, "You filled the gas pump."); GameTextForPlayer(playerid, "~g~PAYDAY +1500 $", 2000, 6); pInfo[playerid][payday] += 1500; return 1; } return SendClientMessage(playerid, COLOR_RED, "Your Truck doesn't have the right Trailer."); } } return SendClientMessage(playerid, COLOR_RED, "You are not sitting in an Job-Truck"); |
if(tInfo[tID[playerid]][tFuelStand] < 100) { for(new i=0; i<sizeof(KraftstoffCars); i++) { if(vID == KraftstoffCars[i][kID]) { if(GetVehicleModel(GetVehicleTrailer(vID)) == 584) { tInfo[tID[playerid]][tFuelStand] = 100; SendClientMessage(playerid, COLOR_YELLOW, "Du hast die Zapfsдule erfolgreich gefьllt."); GameTextForPlayer(playerid, "~g~PAYDAY +1500 $", 2000, 6); pInfo[playerid][payday] += 1500; return 1; } return SendClientMessage(playerid, COLOR_RED, "Dein LKW hat keinen oder nicht den richtigen Auflieger."); } } return SendClientMessage(playerid, COLOR_RED, "Du sitzt nicht in einem Job-LKW."); } return SendClientMessage(playerid, COLOR_RED, "Die Zapfsдule ist voll.");