SA-MP Forums Archive
Where to place this? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Where to place this? (/showthread.php?tid=261431)



Where to place this? - Cjgogo - 13.06.2011

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);
      }



Re: Where to place this? - Skaizo - 13.06.2011

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;
}



Re: Where to place this? - Iphone1234g - 13.06.2011

Ofcourse on playerstatschange!


Re: Where to place this? - Cjgogo - 13.06.2011

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.


Re: Where to place this? - xalith - 13.06.2011

try placing it under OnPlayerUpdate


Re: Where to place this? - Cjgogo - 13.06.2011

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)


Re: Where to place this? - xalith - 13.06.2011

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;


Re: Where to place this? - ricardo178 - 13.06.2011

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.