04.05.2017, 21:39
Well, I was making a Farming system in which the user has to enter 10 different CPs. After entering one, the one should disappear and the other one should come. But the Checkpoint stays at the same place and reappears again and again.
Preview of problem -> http://imgur.com/a/gslKO
The whole code:
I can't really understand what's the error. A help would be appriciated!
Preview of problem -> http://imgur.com/a/gslKO
The whole code:
PHP код:
#include <a_samp>
#include <zcmd>
#include <streamer>
enum FarmerJ
{
TMoney,
Onfarming,
Finished,
EFTimer,
tstamp,
CP1,
CP2,
CP3,
CP4,
CP5,
CP6,
CP7,
CP8,
CP9,
CP10,
M1,
M2,
M3,
M4,
M5,
M6,
M7,
M8,
M9,
M10
};
/*new Float: CheckpointsC[][10] =
{
{699.7277, 1286.4685, 11.2983, 5.0}, // pos2
{763.6042, 1271.3716, 19.6916, 5.0},//pos 3
{741.0443, 1166.6055, 19.4455, 5.0}, //pos 4
{575.7811, 1157.2560, 12.2097, 5.0}, // pos 5
{466.3000, 1159.3514, 7.5807, 5.0}, // pos 6
{645.4191, 1213.5051, 11.2806, 5.0}, // pos1
{388.5491, 1086.0913, 15.7358, 5.0}, //pos 7
{271.6047, 1139.2432, 9.7194, 5.0}, //pos 8
{354.0098, 1134.9053, 9.2518, 5.0}, //pos 9
{520.6189, 1182.1271, 10.0533, 5.0} //pos 10
};*/
new Farmer[MAX_PLAYERS][FarmerJ];
new Harvester;
// new vid;
new CountDownFromAmount;
forward CountDownTimer(playerid);
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Farmer Job test by VisionX");
print("--------------------------------------\n");
Harvester = CreateVehicle(532, 573.2031, 1218.1548, 12.7604, 206.1154, 1, 1, 0);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(Harvester, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(Harvester, 0, lights, alarm, doors, bonnet, boot, objective);
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
CMD:gofarming(playerid, parmas[])
{
Farmer[playerid][Onfarming] = 1;
SendClientMessage(playerid, -1, "You're all set to go on farming now. You can turn your harvester's engine now.");
Farmer[playerid][CP1] = CreateDynamicCP( 645.4191, 1213.5051, 11.2806, 5.0, 0, 0, playerid);
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(GetVehicleModel(vehicleid) == 532 && Farmer[playerid][Onfarming] == 0)
{
SendClientMessage(playerid, -1, "To go farming and earn cash do /gofarming");
}
return 1;
}
public OnPlayerConnect(playerid)
{
Farmer[playerid][Onfarming] = 0;
}
CMD:engine(playerid, vehicleid, parmas[])
{
if(Farmer[playerid][Onfarming] == 1)
{
CountDownFromAmount = 120;
Farmer[playerid][tstamp] = SetTimerEx("CountDownTimer", 999, true, "i", playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(Harvester, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(Harvester, 1, lights, alarm, doors, bonnet, boot, objective);
SendClientMessage(playerid, -1, "You've got 120 secs to complete your route!");
Farmer[playerid][EFTimer] = SetTimerEx("FTimer", 120000, false, "i", playerid);
}
if(Farmer[playerid][Onfarming] == 0 && GetVehicleModel(vehicleid) == 532) return SendClientMessage(playerid, -1, "You have to /gofarming to engine this vehicle! (You can't use this vehicle for public use!)");
return 1;
}
public CountDownTimer(playerid)
{
CountDownFromAmount--;
if(CountDownFromAmount == 0)
{
GameTextForPlayer(playerid,"~b~Time's up!", 5000, 3);
}
}
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
if(checkpointid == Farmer[playerid][CP1])
{
SendClientMessage(playerid, -1, "1st");
new Cash = RandomEx(10, 50);
Farmer[playerid][M1] = GivePlayerMoney(playerid, Cash);
DestroyDynamicCP(Farmer[playerid][CP1]);
Farmer[playerid][CP2] = CreateDynamicCP(699.7277, 1286.4685, 11.2983, 5.0, playerid);
}
if(checkpointid == Farmer[playerid][CP2])
{
SendClientMessage(playerid, -1, "2nd");
new Cash = RandomEx(10, 50);
Farmer[playerid][M2] = GivePlayerMoney(playerid, Cash);
DestroyDynamicCP(Farmer[playerid][CP2]);
Farmer[playerid][CP3] = CreateDynamicCP(763.6042, 1271.3716, 19.6916, 5.0, playerid);
}
if(checkpointid == Farmer[playerid][CP3])
{
SendClientMessage(playerid, -1, "3rd");
new Cash = RandomEx(10, 50);
Farmer[playerid][M3] = GivePlayerMoney(playerid, Cash);
DestroyDynamicCP(Farmer[playerid][CP3]);
Farmer[playerid][CP4] = CreateDynamicCP(741.0443, 1166.6055, 19.4455, 5.0, playerid);
}
if(checkpointid == Farmer[playerid][CP4])
{
SendClientMessage(playerid, -1, "4th");
new Cash = RandomEx(10, 50);
Farmer[playerid][M4] = GivePlayerMoney(playerid, Cash);
DestroyDynamicCP(Farmer[playerid][CP4]);
Farmer[playerid][CP5] = CreateDynamicCP(575.7811, 1157.2560, 12.2097, 5.0, playerid);
}
if(checkpointid == Farmer[playerid][CP5])
{
SendClientMessage(playerid, -1, "5th");
new Cash = RandomEx(10, 50);
Farmer[playerid][M5] = GivePlayerMoney(playerid, Cash);
DestroyDynamicCP(Farmer[playerid][CP5]);
Farmer[playerid][CP6] = CreateDynamicCP(466.3000, 1159.3514, 7.5807, 5.0, playerid);
}
if(checkpointid == Farmer[playerid][CP6])
{
SendClientMessage(playerid, -1, "6th");
new Cash = RandomEx(10, 50);
Farmer[playerid][M6] = GivePlayerMoney(playerid, Cash);
DestroyDynamicCP(Farmer[playerid][CP6]);
Farmer[playerid][CP6] = CreateDynamicCP(645.4191, 1213.5051, 11.2806, 5.0, playerid);
}
if(checkpointid == Farmer[playerid][CP7])
{
SendClientMessage(playerid, -1, "7th");
new Cash = RandomEx(10, 50);
Farmer[playerid][M7] = GivePlayerMoney(playerid, Cash);
DestroyDynamicCP(Farmer[playerid][CP7]);
Farmer[playerid][CP7] = CreateDynamicCP(388.5491, 1086.0913, 15.7358, 5.0, playerid);
}
if(checkpointid == Farmer[playerid][CP8])
{
SendClientMessage(playerid, -1, "8th");
new Cash = RandomEx(10, 50);
Farmer[playerid][M8] = GivePlayerMoney(playerid, Cash);
DestroyDynamicCP(Farmer[playerid][CP8]);
Farmer[playerid][CP8] = CreateDynamicCP(354.0098, 1134.9053, 9.2518, 5.0, playerid);
}
if(checkpointid == Farmer[playerid][CP9])
{
SendClientMessage(playerid, -1, "9th");
new Cash = RandomEx(10, 50);
Farmer[playerid][M9] = GivePlayerMoney(playerid, Cash);
DestroyDynamicCP(Farmer[playerid][CP9]);
Farmer[playerid][CP4] = CreateDynamicCP(520.6189, 1182.1271, 10.0533, 5.0, playerid);
}
if(checkpointid == Farmer[playerid][CP10])
{
SendClientMessage(playerid, -1, "10th");
new Cash = RandomEx(10, 50);
Farmer[playerid][M10] = GivePlayerMoney(playerid, Cash);
DestroyDynamicCP(Farmer[playerid][CP10]);
}
return 1;
}
RandomEx(min, max) // By ******
{
return random(max - min) + min;
}
//