SA-MP Forums Archive
Near Location Message - 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: Near Location Message (/showthread.php?tid=114559)



Near Location Message - adsy - 19.12.2009

I am looking to create a teleport command that only works when a player is in the vicinity of a point. The script works but it doesnt display the text BEFORE the command is entered.

here is what i have in my onplayercommandtext

Код:
 if(!IsPlayerInAnyVehicle(playerid)){ //Check to make sure a player is not in a vehicle

    if(IsPlayerInRangeOfPoint(playerid, 4.0, -2409.3364,-2189.7725,34.0391)){

     SendClientMessage(playerid, 0xFFFFFFFF, "Do you need a lift to the top? type /lift");

     if(!strcmp("/lift", cmd)) { //Works with or without the !

        SetPlayerPos(playerid,-2232.8716,-1737.5121,480.8323);

     }
    }
 }



Re: Near Location Message - adsy - 19.12.2009

im guessing im going to have to turn it into a function somehow, but how i go about splitting apart the code for the slash commands is where im going to get stuck.

I still dont know why it works but the text doesnt appear until after i type the command. my guess is because that is in the command lines section it wont run until it gets a command from a player.

the only other thing i can think of is maybe i should be putting something in the onplayerupdate function.


Re: Near Location Message - westre - 20.12.2009

Quote:
Originally Posted by adsy
I am looking to create a teleport command that only works when a player is in the vicinity of a point. The script works but it doesnt display the text BEFORE the command is entered.

here is what i have in my onplayercommandtext

Код:
 if(!IsPlayerInAnyVehicle(playerid)){ //Check to make sure a player is not in a vehicle

   if(IsPlayerInRangeOfPoint(playerid, 4.0, -2409.3364,-2189.7725,34.0391)){

     SendClientMessage(playerid, 0xFFFFFFFF, "Do you need a lift to the top? type /lift");

     if(!strcmp("/lift", cmd)) { //Works with or without the !

       SetPlayerPos(playerid,-2232.8716,-1737.5121,480.8323);

     }
   }
 }
Код:
 
if(!strcmp("/lift", cmd)) 
{ //Works with or without the !
 if(!IsPlayerInAnyVehicle(playerid))
   { //Check to make sure a player is not in a vehicle
    if(IsPlayerInRangeOfPoint(playerid, 4.0, -2409.3364,-2189.7725,34.0391))
     {
     SendClientMessage(playerid, 0xFFFFFFFF, "Do you need a lift to the top? type /lift");
     SetPlayerPos(playerid,-2232.8716,-1737.5121,480.8323);
     }
    }
return 1;
 }



Re: Near Location Message - patchkinson - 20.12.2009

yup, i was late, you need to make it return something, in this case a simple return 1; would fix it!


Re: Near Location Message - DiddyBop - 20.12.2009

or put a checkpoint there.. walk into it it sets ur position..


Re: Near Location Message - adsy - 20.12.2009

Quote:
Originally Posted by patchkinson
yup, i was late, you need to make it return something, in this case a simple return 1; would fix it!
DOH!!!

edit: ok

tested it now and still not getting a result.

i could use the checkpoint thing but shouldnt the inrangeofpoint function work in EXACTLY the same way?

plus i would want the user to determine whether they want to go and teleport to the location.


Re: Near Location Message - adsy - 20.12.2009

ok well i came up with a fix that seems ok to me

this is the script in the onplayercommandtext:
Код:
if(!IsPlayerInAnyVehicle(playerid)){ //Check to make sure a player is not in a vehicle

    if(IsPlayerInRangeOfPoint(playerid, 4.0, -2409.3364,-2189.7725,34.0391)){
     if(!strcmp("/lift", cmd)) { //Works with or without the !
        SetPlayerPos(playerid,-2232.8716,-1737.5121,480.8323);
     }
    }
    return 1;
 }
I then added to other sections some more bits:

at the top with other "new" commands:

Код:
new mountain;
in ongamemodeinit i added this:

Код:
mountain = CreatePickup(1239, 19, -2409.3364,-2189.7725,34.0391, 0);
this is a line to create an information symbol

and finally

i created this:

Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
  if(pickupid == mountain){
SendClientMessage(playerid, 0xFFFFFFFF, "Do you need a lift to the top? type /lift");
  } 
}
im going to see if i can find a better info symbol now

this one is the " i " symbol.

any objectid suggestions?