for(new c = 0; c < 7; c++)
{
DestroyDynamicCP(DrivingCheck[playerid][c]);
DrivingCheck[playerid][c] = -1;
}
for(new x = 0; x < 8; x++)
{
DestroyDynamicRaceCP(SweepCheck[playerid][x]);
SweepCheck[playerid][x] = -1;
}
for(new y = 0; y < 3; y++)
{
DestroyDynamicCP(TruckCheck[playerid][y]);
TruckCheck[playerid][y] = -1;
}
for(new z = 0; z < 3; z++)
{
DestroyDynamicCP(TrashCheck[playerid][z]);
TrashCheck[playerid][z] = -1;
}
for(new a = 0; a < 2; a++)
{
DestroyDynamicCP(PizzaCheck[playerid][a]);
PizzaCheck[playerid][a] = -1;
}
else if(checkpointid == PizzaCheck[playerid][1])
{
format(string, sizeof(string), "Pizza Delivery Job: "COL_WHITE"Well done! You have earned a total of "COL_GREEN"$%s on this job.", AddCommas(PizzaTips[playerid]));
SendClientMessage(playerid, COLOUR_REALRED, string);
DestroyDynamicCP(PizzaCheck[playerid][1]);
RemovePlayerMapIcon(playerid, 0);
PlayerMoney[playerid] += PizzaTips[playerid];
GivePlayerMoney(playerid, PizzaTips[playerid]);
SetVehicleToRespawn(PizzaBikeID[playerid]);
PizzaCooldown[playerid] = 5;
PizzaJob[playerid] = 0;
PizzaBikeID[playerid] = -1;
PizzaAmount[playerid] = 0;
PizzaTips[playerid] = 0;
RemovePlayerFromVehicle(playerid);
new skin = GetPlayerSkinEx(playerid);
SetPlayerSkin(playerid, skin);
MySQL_SetInteger(PlayerSQLID[playerid], "PizzaCooldown" , 5, "accounts");
for(new x = 0; x < 2; x++)
{
DestroyDynamicCP(PizzaCheck[playerid][x]);
PizzaCheck[playerid][x] = -1;
}
}
else if(checkpointid == PizzaCheck[playerid][0])
{
new tip, maxhouse;
if(PizzaJob[playerid] == 1)
{
if(!IsPlayerAttachedObjectSlotUsed(playerid, 0))return SendClientMessage(playerid, COLOUR_GREY, "Use /getpizza at your delivery bike before entering the checkpoint.");
RemovePlayerAttachedObject(playerid, 0);
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
if(PizzaAmount[playerid] < 4)
{
PizzaAmount[playerid] ++;
}
new chance = RandomEx(1, 10000);
if(chance < 10000)
{
tip = RandomEx(1, 45);
format(string, sizeof(string), "PIZZA DELIVERED: "COL_WHITE"You received a tip of "COL_GREEN"$%d "COL_WHITE"for delivering this pizza.", tip);
SendClientMessage(playerid, COLOUR_REALRED, string);
}
if(chance == 10000)
{
format(string, sizeof(string), "PIZZA DELIVERED: "COL_WHITE"You received an "COL_ORANGE"INCREDIBLE "COL_WHITE"tip of "COL_GREEN"$10,000.");
tip = 10000;
SendClientMessage(playerid, COLOUR_REALRED, string);
}
PizzaTips[playerid] += tip;
ServerStartMoney += tip;
if(PizzaAmount[playerid] == 4)
{
RemovePlayerMapIcon(playerid, 0);
format(string, sizeof(string), "Pizza Delivery Job: "COL_WHITE"Please return the bike to the Pizza Stack to collect your payment.");
SendClientMessage(playerid, COLOUR_REALRED, string);
PizzaCheck[playerid][1] = CreateDynamicCP(VehSpawnX[PizzaBikeID[playerid]], VehSpawnY[PizzaBikeID[playerid]], VehSpawnZ[PizzaBikeID[playerid]], 2, 0, 0, playerid, 100.0);
DestroyDynamicCP(PizzaCheck[playerid][0]);
SetPlayerMapIcon(playerid, 0, VehSpawnX[PizzaBikeID[playerid]], VehSpawnY[PizzaBikeID[playerid]], VehSpawnZ[PizzaBikeID[playerid]], 0, COLOUR_RED, MAPICON_LOCAL);
}
else
{
for(new x = 1; x < MAX_HOUSES; x++)
{
if(HouseEntX[x] != 0)
{
maxhouse++;
}
}
new house = RandomEx(1, maxhouse);
RemovePlayerMapIcon(playerid, 0);
if(HouseEntVW[house] > 0)
{
for(new a = 1; a < MAX_APARTS; a++)
{
if(HouseVW[house] == ApartVW[a])
{
format(string, sizeof(string), "Pizza Order Address: "COL_ORANGE"%s, "COL_WHITE"please proceed to the checkpoint on your map to deliver the pizza.", ApartName[a]);
SendClientMessage(playerid, COLOUR_WHITE, string);
PizzaCheck[playerid][0] = CreateDynamicCP(ApartEntX[a], ApartEntY[a], ApartEntZ[a], 2, 0, 0, playerid, 100.0);
SetPlayerMapIcon(playerid, 0, ApartEntX[a], ApartEntY[a], ApartEntZ[a], 0, COLOUR_RED, MAPICON_LOCAL);
}
}
}
else
{
format(string, sizeof(string), "Pizza Order Address: "COL_ORANGE"%s, "COL_WHITE"please proceed to the checkpoint on your map to deliver the pizza.", HouseName[house]);
SendClientMessage(playerid, COLOUR_WHITE, string);
PizzaCheck[playerid][0] = CreateDynamicCP(HouseEntX[house], HouseEntY[house], HouseEntZ[house], 2, 0, 0, playerid, 100.0);
DestroyDynamicCP(PizzaCheck[playerid][0]);
SetPlayerMapIcon(playerid, 0, HouseEntX[house], HouseEntY[house], HouseEntZ[house], 0, COLOUR_RED, MAPICON_LOCAL);
}
}
}
}
Why can't I use ToggleDynamicCP? As opposed to that.
I'm extremely confused and find this hard to understand. |
Where should I create the Checkpoints and also should they be local or global in this case?
|
for(new c = 0; c < 7; c++) { TogglePlayerDynamicCP(playerid, CheckPoint_1, 0); // hide CP 1 TogglePlayerDynamicCP(playerid, CheckPoint_2, 1); // show CP 2 DrivingCheck[playerid][c] = -1; }
// global:
new PizzaCheck[2];
// in OnGameModeInit:
PizzaCheck[0] = CreateDynamicCP(..);
PizzaCheck[1] = CreateDynamicCP(..);
// When a player connects:
for(new a = 0; a < sizeof PizzaCheck; a++)
{
TogglePlayerDynamicCP(playerid, PizzaCheck[a], 0);
}
PizzaCheck[playerid][0] = CreateDynamicCP(HouseEntX[house], HouseEntY[house], HouseEntZ[house], 2, 0, 0, playerid, 100.0);
DestroyDynamicCP(PizzaCheck[playerid][0]);
Dynamic checkpoints are used if you want to display many of them at a time. If what you are trying to do is like missions that goes from one checkpoint to another, you may as well use SetPlayerCheckpoint but that would be more confusing as there would too much variables checking. Now, as you have it with dynamic checkpoints: create all checkpoints once (when the server starts) like:
pawn Код:
|
UpdateDynamicCPPos(cpid, Float: cpx, Float: cpy, Float: cpz)
{
return Streamer_SetFloatData(STREAMER_TYPE_CP, cpid, E_STREAMER_X, cpx) && Streamer_SetFloatData(STREAMER_TYPE_CP, cpid, E_STREAMER_Y, cpy) && Streamer_SetFloatData(STREAMER_TYPE_CP, cpid, E_STREAMER_Z, cpz);
}