Near Location Message
#1

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

     }
    }
 }
Reply
#2

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

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;
 }
Reply
#4

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

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

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

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?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)