|
you can use checkpoints to player position and when the medic got to checkpoint you send him a message or you can use onplayerupdate if player is streamed in with otherplayer which called the medic just send him the message
so in total usefull functions : IsVehicleStreamedIn <To check the medic vehicle stream in on player update> IsPlayerStreamedIn those functions should be usefull in OnPlayerUpdate or use of checkpoints |
publice OnPlayerUpdate(playerid)
{
if(IsPlayerCalled[playerid])
{
if(IsPlayerStreamedIn(PlayerCallAccepterId))
{
SendMessage("Paramedic Arrived");
IsPlayerCalled[playerid] = false;
}
}
return 1;
}
|
Just check the distance between the worker and the caller every second, if distance is <30 for example, send the message.
Useful functions: SetTimer, GetPlayerDistanceFromPoint I suggest creating variable called: iskvietejoID[MAX_PLAYERS]; |
SetTimer("OnOneSecondPass", 1000, true);
new iskvietejoID[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
iskvietejoID[playerid] = INVALID_PLAYER_ID;
}
iskvietejoID[playerid] = targetid;
forward OnOneSecondPass();
public OnOneSecondPass()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(iskvietejoID[i] != INVALID_PLAYER_ID)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(i, x, y, z);
new Float:atstumas = GetPlayerDistanceFromPoint(iskvietejoID[i], x, y, z);
if(atstumas <= 30.0)
{
SendClientMessage(iskvietejoID[i], -1, "Medikas atvyko (čia tikrinsi pagal profesiją)");
iskvietejoID[i] = INVALID_PLAYER_ID;
}
}
}
}
}
public OnPlayerDisconnect(playerid, reason)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(iskvietejoID[i] == playerid)
{
SendClientMessage(i, -1, "Tavo klientas atsijungė");
iskvietejoID[i] = INVALID_PLAYER_ID;
}
}
}
}
rep duosiu
viskas net aiškiau pasidaro xdd
|
Just check the distance between the worker and the caller every second, if distance is <30 for example, send the message.
Useful functions: SetTimer, GetPlayerDistanceFromPoint I suggest creating variable called: iskvietejoID[MAX_PLAYERS]; |
|
why ? there is no need of another timer for each second when there is almost a timer
public OnPlayerUpdate |