ClientMessage keeps repeating...
#1

The following thing keeps repeating itself...
It just spams player in range with:
This property is for sale
OR
You're standing on %s's porch. Use /enter to go in.

Can anyone tell me how to fix this?

pawn Код:
function:OnPlayerNearProperty()
{
    foreach(new i : Player)
    {
        if(PlayerInfo[i][pLoggedin] == false)
            continue;
           
        for(new p = 1; p < MAX_PROPERTY; p++)
        {
            if(!PropertyInfo[p][ePropertyDBID])
                continue;
               
            if(IsPlayerInRangeOfPoint(i, 3.0, PropertyInfo[p][ePropertyEntrance][0], PropertyInfo[p][ePropertyEntrance][1], PropertyInfo[p][ePropertyEntrance][2]))
            {
                if(GetPlayerInterior(i) != PropertyInfo[p][ePropertyEntranceInterior])
                    continue;
                   
                if(GetPlayerVirtualWorld(i) != PropertyInfo[p][ePropertyEntranceWorld])
                    continue;
       
                if(!PropertyInfo[p][ePropertyOwnerDBID])
                {
                    SendClientMessage(i, COLOR_DARKGREEN, "This property is for sale. Use /buyproperty.");
                    SendClientMessageEx(i, COLOR_DARKGREEN, "Price: $%i", PropertyInfo[p][ePropertyMarketPrice]);
                }
                else
                {
                    SendClientMessageEx(i, COLOR_DARKGREEN, "You're standing on %s's porch. Use /enter to go in.",  ReturnDBIDName(PropertyInfo[p][ePropertyOwnerDBID]));
                }  
            }
        }
    }
    return 1;
}
Reply
#2

Quote:
Originally Posted by NLDBrian
Посмотреть сообщение
The following thing keeps repeating itself...
It just spams player in range with:
This property is for sale
OR
You're standing on %s's porch. Use /enter to go in.

Can anyone tell me how to fix this?

[pawn]
function:OnPlayerNearProperty()
{
foreach(new i : Player)
{
if(PlayerInfo[i][pLoggedin] == false)
continue;

for(new p = 1; p < MAX_PROPERTY; p++)
{
if(!PropertyInfo[p][ePropertyDBID])
continue;

if(IsPlayerInRangeOfPoint(i, 3.0, PropertyInfo[p][ePropertyEntrance][0], PropertyInfo[p][ePropertyEntrance][1], PropertyInfo[p][ePropertyEntrance][2]))
{
if(GetPlayerInterior(i) != PropertyInfo[p][ePropertyEntranceInterior])
continue;

if(GetPlayerVirtualWorld(i) != PropertyInfo[p][ePropertyEntranceWorld])
continue;

if(!PropertyInfo[p][ePropertyOwnerDBID])
{
SendClientMessage(i, COLOR_DARKGREEN, "This property is for sale. Use /buyproperty.");
SendClientMessageEx(i, COLOR_DARKGREEN, "Price: $%i", PropertyInfo[p][ePropertyMarketPrice]);
}
else
{
SendClientMessageEx(i, COLOR_DARKGREEN, "You're standing on %s's porch. Use /enter to go in.", ReturnDBIDName(PropertyInfo[p][ePropertyOwnerDBID]));
}
}
}
}
return 1;
}
[/[pawn]
Your problem is that you do not have to check if the player is close to x place because when this place near X will send you infinite messages, to solve your problem I suggest you create a Pickup of the property.


I will give you an example, where you have your properties, add I am in the loaded when you create it, that will be the picukp

PHP код:
new PickUpPropertyInfo[MAX_PROPERTY]; 
When you load them or create them

PHP код:
PickUpPropertyInfo[propertyid] = CreatePickup(12722PropertyInfo[propertyid][ePropertyEntrance][0], PropertyInfo[propertyid][ePropertyEntrance][1], PropertyInfo[propertyid][ePropertyEntrance][2]);
//Remember that propertyid you have to change depending on where you add it 
PHP код:
public OnPlayerPickUpPickup(playeridpickupid)
{
    for(new 
1MAX_PROPERTYi++)
    {
        if(
pickupid == PickUpPropertyInfo[i])
        {
            
//In here you put the code you want me to send
        
}
    }    
    return 
1;

I have never used onplayerpickuppikup but according to me when you grab it you only teach it once and then if you pick it up again it shows you the message
Reply
#3

OnPlayerPickupPickup is buggy, i rather using dynamic areas instead of pickups.
Reply
#4

Quote:
Originally Posted by Swankeh
Посмотреть сообщение
Your problem is that you do not have to check if the player is close to x place because when this place near X will send you infinite messages, to solve your problem I suggest you create a Pickup of the property.


I will give you an example, where you have your properties, add I am in the loaded when you create it, that will be the picukp

PHP код:
new PickUpPropertyInfo[MAX_PROPERTY]; 
When you load them or create them

PHP код:
PickUpPropertyInfo[propertyid] = CreatePickup(12722PropertyInfo[propertyid][ePropertyEntrance][0], PropertyInfo[propertyid][ePropertyEntrance][1], PropertyInfo[propertyid][ePropertyEntrance][2]);
//Remember that propertyid you have to change depending on where you add it 
PHP код:
public OnPlayerPickUpPickup(playeridpickupid)
{
    for(new 
1MAX_PROPERTYi++)
    {
        if(
pickupid == PickUpPropertyInfo[i])
        {
            
//In here you put the code you want me to send
        
}
    }    
    return 
1;

I have never used onplayerpickuppikup but according to me when you grab it you only teach it once and then if you pick it up again it shows you the message
So if I understand this right if i have 5 properties i have to make 5 pickups? and each one:
PHP код:
PickUpPropertyInfo[1] = CreatePickup(12722PropertyInfo[1]........ 
Reply
#5

I guess you are calling the function continuously. If so, define a new variable, and call the function only when the variable reaches the required value.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)