Client message when near pickup
#1

I'm trying to make a message appear when you get near the pickup to enter a building.

Currently the way I have it, the message pops up after you use the /enter command.

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if(!
strcmp(cmdtext"/enter"true))
    {
        if(
IsPlayerInRangeOfPoint(playerid3.02622.90942754.118412.5452))
        
SendClientMessageToAll(0xFFFFFFFF,"Type /enter to enter!");
        {
            
SetPlayerPos(playerid238.6620,141.0520,1003.0234);//FBI Entrance
            
SetPlayerInterior(playerid3);
        }
        if(
IsPlayerInRangeOfPoint(playerid3.02659.5286,2753.1008,12.5377))
           
SendClientMessageToAll(0xFFFFFFFF,"Type /enter to enter!");
        {
            
SetPlayerPos(playerid249.8472,181.9114,1003.0234);//Rear FBI Entrance
            
SetPlayerInterior(playerid3);
        }
    } 
Any help is appreciated!
Reply
#2

Код:
Create3DTextLabel(text[], color, Float:X, Float:Y, Float:Z, Float:DrawDistance, virtualworld, testLOS)
Replace SendClientMessageToAll with that ^
Check on the wiki if you don't understand
https://sampwiki.blast.hk/wiki/Create3DTextLabel
Reply
#3

Why don't you use OnPlayerPickUpPickup
Reply
#4

Quote:
Originally Posted by Glint
Посмотреть сообщение
Why don't you use OnPlayerPickUpPickup
I just attempted and failed.


PHP код:
new Entrance;
new 
Exitpoint;
public 
OnGameModeInit()
{
    
//Entrance & Exits
    
Entrance AddStaticPickup(123912622.9094,2754.1184,12.5452, -1);//FBI Entrance
    
Exitpoint AddStaticPickup(12391,238.6524,140.3135,1003.0234, -1);//FBI Exit
    
Entrance AddStaticPickup(12391,2659.5286,2753.1008,12.5377, -1);//FBI Rear Entrance
    
Exitpoint AddStaticPickup(12391,249.6860,181.7354,1003.0234, -1);//FBI Rear Exit
    
return 1;
}
public 
OnPlayerPickUpPickup(playeridpickupid)
{
    if(
pickupid == Entrance)
    {
    
SendClientMessage(playerid,0xFFFFFFFF,"Type /enter to enter!");
    }
    
    if(
pickupid == Exitpoint)
    {
    
SendClientMessage(playerid,0xFFFFFFFF,"Type /exit to exit!");
    }
    return 
1;

For some reason the only one that pops up with the text, is the one on the inside, and it shows both client messages.
Reply
#5

Quote:
Originally Posted by spawnzlive
Посмотреть сообщение
I just attempted and failed.


PHP код:
new Entrance;
new 
Exitpoint;
public 
OnGameModeInit()
{
    
//Entrance & Exits
    
Entrance AddStaticPickup(123912622.9094,2754.1184,12.5452, -1);//FBI Entrance
    
Exitpoint AddStaticPickup(12391,238.6524,140.3135,1003.0234, -1);//FBI Exit
    
Entrance AddStaticPickup(12391,2659.5286,2753.1008,12.5377, -1);//FBI Rear Entrance
    
Exitpoint AddStaticPickup(12391,249.6860,181.7354,1003.0234, -1);//FBI Rear Exit
    
return 1;
}
public 
OnPlayerPickUpPickup(playeridpickupid)
{
    if(
pickupid == Entrance)
    {
    
SendClientMessage(playerid,0xFFFFFFFF,"Type /enter to enter!");
    }
    
    if(
pickupid == Exitpoint)
    {
    
SendClientMessage(playerid,0xFFFFFFFF,"Type /exit to exit!");
    }
    return 
1;

For some reason the only one that pops up with the text, is the one on the inside, and it shows both client messages.
OnPlayerPickUpPickup works only with CreatePickup not AddStaticPickup so try to use that.
Reply
#6

Try this :
PHP код:
new Entrance
new 
Exitpoint
new 
Entrance1;
New 
Exitpoint1;
public 
OnGameModeInit() 

    
//Entrance & Exits 
    
Entrance CreatePickup(123912622.9094,2754.1184,12.5452, -1);//FBI Entrance 
    
Exitpoint CreatePickup(12391,238.6524,140.3135,1003.0234, -1);//FBI Exit 
    
Entrance1 CreatePickup(12391,2659.5286,2753.1008,12.5377, -1);//FBI Rear Entrance 
    
Exitpoint1 CreatePickup(12391,249.6860,181.7354,1003.0234, -1);//FBI Rear Exit 
    
return 1

public 
OnPlayerPickUpPickup(playeridpickupid

    if(
pickupid == Entrance
    { 
    
SendClientMessage(playerid,0xFFFFFFFF,"Type /enter to enter!"); 
    } 
     
    if(
pickupid == Exitpoint
    { 
    
SendClientMessage(playerid,0xFFFFFFFF,"Type /exit to exit!"); 
    } 
     if(
pickupid == Entrance1
    { 
    
SendClientMessage(playerid,0xFFFFFFFF,"Type /enter to enter!"); 
    } 
    if(
pickupid == Exitpoint1
    { 
    
SendClientMessage(playerid,0xFFFFFFFF,"Type /exit to exit!"); 
    } 
    return 
1

Reply
#7

Quote:
Originally Posted by CreatePickup SA:MP Wiki
This function does exactly the same as AddStaticPickup, except it returns a pickup ID which can be used to destroy it afterwards and be tracked using OnPlayerPickUpPickup.
As the wiki says AddStaticPickup doesn't return the id of the pickup so it won't work.

You need CreatePickup
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)