Where to place this?
#1

OK,look,I made a code like a radar system(switiching problem to other topic),and now evrything is fixed just that I don't know where I should put the code:

pawn Code:
if(IsPlayerInRangeOfPoint(playerid,40.0,-2013.1947,-61.9978,35.3203) && IsPlayerInAnyVehicle(playerid))
      {
         GetPlayerSpeed(playerid,true);
         new string[128];
         new pName[MAX_PLAYER_NAME];
         GetPlayerName(playerid,pName,sizeof(pName));
         format(string,sizeof(string),"RadarInfo:%s(%d)-speed = %d",pName,playerid,GetPlayerSpeed(playerid,true));
         SendClientMessageToAll(COLOR_BLUE,string);
      }
Reply
#2

Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new vehicleid=GetPlayerVehicleID(playerid);
    if(newstate == PLAYER_STATE_DRIVER)
    {
       SetVehicleParamsEx(vehicleid,0,0,0,0,0,0,0);
       SendClientMessage(playerid,COLOR_PURPLE,"Press 2 to toggle engine");
    }
    if(newstate == PLAYER_STATE_DRIVER)
    {
      if(IsPlayerInRangeOfPoint(playerid,20.0,-2013.1947,-61.9978,35.3203))
      {
         GetPlayerSpeed(playerid,true);
         new string[128];
         new pName[MAX_PLAYER_NAME];
         GetPlayerName(playerid,pName,sizeof(pName));
         format(string,sizeof(string),"RadarInfo:%s(%d)-speed = %d",pName,playerid,GetPlayerSpeed(playerid,true));
         SendClientMessageToAll(COLOR_BLUE,string);
    }
    return 1;
}
you must i think :
Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new vehicleid=GetPlayerVehicleID(playerid);
    if(newstate == PLAYER_STATE_DRIVER)
    {
       SetVehicleParamsEx(vehicleid,0,0,0,0,0,0,0);
       SendClientMessage(playerid,COLOR_PURPLE,"Press 2 to toggle engine");
    }
    if(newstate == PLAYER_STATE_DRIVER)
    {
      if(IsPlayerInRangeOfPoint(playerid,20.0,-2013.1947,-61.9978,35.3203))
      {
         new string[128];
         new pName[MAX_PLAYER_NAME];
         GetPlayerName(playerid,pName,sizeof(pName));
         format(string,sizeof(string),"RadarInfo:%s(%d)-speed = %d",pName,playerid,GetPlayerSpeed(playerid,true),GetPlayerSpeed(playerid,false));
         SendClientMessageToAll(COLOR_BLUE,string);
      }
    }
    return 1;
}
Reply
#3

Ofcourse on playerstatschange!
Reply
#4

If I place it at OnPlaterStateChnage,ONLY when I enter a car near that point(ENTER NOT DRIVING),it gives me radar Info,otherwise if I'm driving by,it does not.
Reply
#5

try placing it under OnPlayerUpdate
Reply
#6

thanks xalith but now when I apss by it spammes all the chat with a few speeds,until I leave that area xD(how to make it gonna show only 1 client message)
Reply
#7

pawn Code:
new msg[MAX_PLAYERS]; // add this to the top of your code
              if(IsPlayerInRangeOfPoint(playerid,40.0,-2013.1947,-61.9978,35.3203) && IsPlayerInAnyVehicle(playerid))
      {  if( msg[playerid] == 0){
         GetPlayerSpeed(playerid,true);
         new string[128];
         new pName[MAX_PLAYER_NAME];
         GetPlayerName(playerid,pName,sizeof(pName));
         format(string,sizeof(string),"RadarInfo:%s(%d)-speed = %d",pName,playerid,GetPlayerSpeed(playerid,true));
         SendClientMessageToAll(COLOR_BLUE,string);
          msg[playerid] = 1;
      }
}
this will send the message only once, you should reset it at onplayerdeath and stuff so if they die and come back again or under onplayerstatechange add msg[playerid] = 0;
Reply
#8

Why do you say that: I made a code, but i don't know how to put it...
If you know script enough to make a code, you know where to put it...
Thats my opinion.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)