truck job
#1

hello, i have been working on my truck job and i've got a weird error. when i do /buyprod in truck 1, it sais i have to be in a truck. when i am in truck 2, it sais i bought a trailer and it adds a trailer to truck 1.... i want to have it like, truck 1: trailer 1, truck 2: trailer to, etc. this is my script:

Код:
	if(!strcmp("/buyprod", cmdtext, true,9))
	for(new i; i<sizeof(truck); i++)
 	{
 	if(GetPlayerMoney(playerid)<=499)
 		return SendClientMessage(playerid,COLOR_RED,"You don't have $500");
  if(!PlayerToPoint(30.0,playerid,-1834.4691, 129.1151, 15.1171))
    return SendClientMessage(playerid, COLOR_RED, "You have to be at the truck loadstation");
  if(!IsPlayerInVehicle(playerid, truck[1]))
    return SendClientMessage(playerid, COLOR_RED, "You have to be in a truck!");
  GivePlayerMoney(playerid,-500);
  SendClientMessage(playerid, COLOR_GREEN, "You have bought products for $500.");
  CP1truckerjob = CreateCheckpoint(-1866.2645, 1409.7406, 7.7822, 10.0, 9999.9, "CP1truckerjob",true);
  return AttachTrailerToVehicle(trailer[i],truck[i]);
 	}
further i have this:
Код:
new truck[5];
new trailer[5];
and the trucks identified of course

could anyone help me with it??..
Reply
#2

So if I understand this right, the trucks are vehicleid's? So truck[1] is a vehicleid right?
Reply
#3

yup, it's truck [ 0 ] to truck [ 4 ] (without spaces then, else the editor would flip). so 5 trucks. but it wont work, so i think there is a problem in this line:
Код:
for(new i; i<sizeof(truck); i++)
Reply
#4

you could try
Quote:

while(i < sizeof(truck)
{
Your codes here
i++
}

Dont know why but somethimes for() didn't work for me either :S
Reply
#5

nope, wont work.... man difficult problem. no-one knows the prob...
Reply
#6

Try this:

Код:
Quote:
if(!strcmp("/buyprod", cmdtext, true,9)) { for(new i; i<sizeof(truck); i++) { if(GetPlayerMoney(playerid)<=499) return SendClientMessage(playerid,COLOR_RED,"You don't have $500"); if(!PlayerToPoint(30.0,playerid,-1834.4691, 129.1151, 15.1171)) return SendClientMessage(playerid, COLOR_RED, "You have to be at the truck loadstation"); if(IsPlayerInVehicle(playerid, truck[i])) { GivePlayerMoney(playerid,-500); SendClientMessage(playerid, COLOR_GREEN, "You have bought products for $500."); CP1truckerjob = CreateCheckpoint(-1866.2645, 1409.7406, 7.7822, 10.0, 9999.9, "CP1truckerjob",true); return AttachTrailerToVehicle(trailer[i],truck[i]); } else return SendClientMessage(playerid, COLOR_RED, "You have to be in a truck!"); } }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)