#1

https://pastebin.com/m0GpVCAH
This is commands to call Medic, Policeman and taxi worker.
How to do, what when worker arrives to client auto send message? ex.: "Paramedic arrived!"
Reply
#2

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
Reply
#3

Quote:
Originally Posted by khRamin78
View Post
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
Did possible to create invisible checkpoint?
Reply
#4

Quote:
Originally Posted by Heress
View Post
Did possible to create invisible checkpoint?
no its not possible maybe using checkpoints with different interior and vw with streamer would do that but its useless you can use like this if yo want something invisible
PHP Code:
publice OnPlayerUpdate(playerid)
{
 if(
IsPlayerCalled[playerid])
{
 if(
IsPlayerStreamedIn(PlayerCallAccepterId))
{
 
SendMessage("Paramedic Arrived");
 
IsPlayerCalled[playerid] = false;
}
}
 return 
1;

Reply
#5

https://pastebin.com/m0GpVCAH

What PlayerCallAcceptedId should be in my code?
Floats tx, ty and tz is global
Reply
#6

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];
Reply
#7

Quote:
Originally Posted by lollypap54
View Post
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];
Logiљka, o kaip turėtų atrodyti update timer'is? SetTimer("DistanceUpdateTimer", 1000 ...ir kaip toliau?

It's logic. How will look update timer?
Reply
#8

Timerio kvietimas, gali į main() arba OnGameModeInit() dėt:
Code:
SetTimer("OnOneSecondPass", 1000, true);
Tas kintamasis:
Code:
new iskvietejoID[MAX_PLAYERS];
Jį reikėtų nustatyt į INVALID_PLAYER_ID iљ pradћių(nu nes jokio iљkvietėjo dar nebūna xd):
Code:
public OnPlayerConnect(playerid)
{
     iskvietejoID[playerid] = INVALID_PLAYER_ID;
}
Toliau, /priimti komandoj kai jau gauni targetid raљai:
Code:
iskvietejoID[playerid] = targetid;
Dabar su ta 1 sekunde (P.S patariu loopint ћaidėjus su foreach, raљau su tuo MAX_PLAYERS tik dėl to, kad tu taip raљai):
Code:
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;
                  }
            }
        }
     }
}
Bet dar ne viskas, jeigu iљkvietėjas atsijungtų, tas tikrinimas toliau eitų, tai tau reik daryt:
Code:
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;
              }
          }
      }
}
Nu va, tikiuos viskas čia gerai xd
Reply
#9

Dėkui labai tau rep duosiu viskas net aiškiau pasidaro xdd
Reply
#10

Quote:
Originally Posted by lollypap54
View Post
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
Reply
#11

Quote:
Originally Posted by khRamin78
View Post
why ? there is no need of another timer for each second when there is almost a timer

public OnPlayerUpdate
whatever i already fixed it
Reply
#12

Quote:
Originally Posted by Heress
View Post
whatever i already fixed it
fixxing it in bad way isnt good idea anyway goodluck
Reply
#13

OnPlayerUpdate callback happens about 30 times a second, so we use it when we REALLY need it, for this 1 second check is enough
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)