hook OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys == KEY_SUBMISSION)
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendDebug(playerid, "Check: 1");
new model = GetVehicleModel(GetPlayerVehicleID(playerid));
if(model != 431 && model != 437) return SendDebug(playerid, "Check: 2");
if(IsValidDynamicCP(pJobCP[playerid])) return SendDebug(playerid, "Check: 3");
new RandomCpID = random(sizeof(BusJobCP));
pJobCP[playerid] = CreateDynamicCP(BusJobCP[RandomCpID][PosX], BusJobCP[RandomCpID][PosY], BusJobCP[RandomCpID][PosZ],2.0, -1, -1, playerid, 1000.0);
SendDebug(playerid,"PosX: %f, PosY: %f, PosZ: %f", BusJobCP[RandomCpID][PosX], BusJobCP[RandomCpID][PosY], BusJobCP[RandomCpID][PosZ]);
}
return 1;
}
The streamer is programmed and designed to always show the closest checkpoint. Chances are that the newly created isn't the closest so it is simply not created and hence not shown on the map either. In order to show a checkpoint on the map you should probably use a map icon instead. You can use map icon id 0 with color red to mimic the default checkpoint icon, or you can choose any color you want. When the player gets near the checkpoint will show up for them and once they enter it you can remove the map icon.
|
//==============================================================================
//--->>> Bus Job
//==============================================================================
#include <a_samp>
#include <YSI\y_hooks>
//==============================================================================
enum BusJob
{
Float:PosX,
Float:PosY,
Float:PosZ
};
static const BusJobCP[][BusJob] =
{
{2424.8142,2285.3069,10.6719},
{2392.5549,2415.5117,10.6797},
{2305.9316,2515.2656,10.6719}
};
new pJobCP[MAX_PLAYERS];
//==============================================================================
//--->>> Forwards
//==============================================================================
forward BusStop(playerid);
//==============================================================================
//--->>> Hooks
//==============================================================================
hook OnPlayerConnect(playerid)
{
pJobCP[playerid] = 0;
return 1;
}
hook OnPlayerDisconnect(playerid, reason)
{
if(IsValidDynamicCP(pJobCP[playerid]))
{
DestroyDynamicCP(pJobCP[playerid]);
pJobCP[playerid] = 0;
}
return 1;
}
hook OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new model = GetVehicleModel(GetPlayerVehicleID(playerid));
if(model == 431 || model == 437)
{
ShowPlayerNotification(playerid, "Press ~g~2 ~w~to start bus job.");
}
}
else if(oldstate == PLAYER_STATE_DRIVER)
{
if(pJobCP[playerid] != 0)
{
if(IsValidDynamicCP(pJobCP[playerid]))
{
DestroyDynamicCP(pJobCP[playerid]);
}
pJobCP[playerid] = 0;
ShowPlayerNotification(playerid, "~r~You have left the vehicle!");
}
}
return 1;
}
hook OnPlayerEnterDynamicCP(playerid, checkpointid)
{
if(checkpointid == pJobCP[playerid])
{
DestroyDynamicCP(pJobCP[playerid]);
TogglePlayerControllable(playerid, 0);
SetTimerEx("BusStop", 5000, false, "d", playerid);
}
return 1;
}
CMD:testjob(playerid, params[])
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendDebug(playerid, "Check: 1");
new model = GetVehicleModel(GetPlayerVehicleID(playerid));
if(model != 431 && model != 437) return SendDebug(playerid, "Check: 2");
if(IsValidDynamicCP(pJobCP[playerid])) return SendDebug(playerid, "Check: 3");
new RandomCpID = random(sizeof(BusJobCP));
pJobCP[playerid] = CreateDynamicCP(BusJobCP[RandomCpID][PosX], BusJobCP[RandomCpID][PosY], BusJobCP[RandomCpID][PosZ], 6.0, -1, -1, playerid, 1000.0);
SendDebug(playerid,"PosX: %f, PosY: %f, PosZ: %f", BusJobCP[RandomCpID][PosX], BusJobCP[RandomCpID][PosY], BusJobCP[RandomCpID][PosZ]);
return 1;
}
hook OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys == KEY_SUBMISSION)
{
}
return 1;
}
//==============================================================================
//--->>> Publics
//==============================================================================
public BusStop(playerid)
{
new RandomCpID = random(sizeof(BusJobCP));
pJobCP[playerid] = CreateDynamicCP(BusJobCP[RandomCpID][PosX], BusJobCP[RandomCpID][PosY], BusJobCP[RandomCpID][PosZ],2.0, -1, -1, playerid, 1000.0);
GameTextForPlayer(playerid, "~y~Payout~n~~w~$2000", 5000, 5);
GivePlayerMoney(playerid, 2000);
TogglePlayerControllable(playerid, 1);
return 1;
}
The streamer is programmed and designed to always show the closest checkpoint. Chances are that the newly created isn't the closest so it is simply not created and hence not shown on the map either. In order to show a checkpoint on the map you should probably use a map icon instead. You can use map icon id 0 with color red to mimic the default checkpoint icon, or you can choose any color you want. When the player gets near the checkpoint will show up for them and once they enter it you can remove the map icon.
|