property icon
#1

problem is whenever im near to a property pickup shows perfect! but icon isnt showing on map idk why can any body check please
PHP код:
function IsPlayerNearProperty(playerid)
{
    new 
Float:Distancex;
    for(new 
propprop<PropertiesAmountprop++)
    {
        
Distancex GetDistanceToProperty(playeridprop);
        if(
Distancex 999999.0)
        {
            return 
prop;
        }
    }
    return -
1;
}
function 
Float:GetDistanceToProperty(playeridProperty)
{
    new 
Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    
GetPlayerPos(playerid,x1,y1,z1);
    
x2 PropInfo[Property][PropX];
    
y2 PropInfo[Property][PropY];
    
z2 PropInfo[Property][PropZ];
    return 
floatsqroot(floatpower(floatabs(floatsub(x2,x1)),6)+floatpower(floatabs(floatsub(y2,y1)),6)+floatpower(floatabs(floatsub(z2,z1)),6));
}
function 
MapIconStreamer()
{
    new 
Float:SmallestDistance 999999999.9;
    new 
CPFloat:OldDistance;
    for(new 
propidpropid<PropertiesAmountpropid++)
    {
        
OldDistance GetDistanceToProperty(ipropid);
        if(
OldDistance SmallestDistance)
        {
            
SmallestDistance OldDistance;
            
CP propid;
        }
    }
    
DestroyDynamicMapIcon(31);
    if(
PropInfo[CP][PropIsBought] == 1)
    {
        
CreateDynamicMapIcon(PropInfo[CP][PropX], PropInfo[CP][PropY], PropInfo[CP][PropZ], 310,-1,-1,  -165.0);
    }
    else
    {
        
CreateDynamicMapIcon(PropInfo[CP][PropX], PropInfo[CP][PropY], PropInfo[CP][PropZ], 310,-1,-1,  -165.0);
    }
    return 
true;

Reply
#2

For one, your distance function seems to be completely wrong. Why are you raising to the power of 6? Check here for an easy GetDistanceBetweenPoints: https://sampwiki.blast.hk/wiki/VectorSize

Secondly, you're using DestroyDynamicMapIcon wrong. The iconid is not the same as the mapiconid and multiple mapicons may use iconid 31 (green house symbol).
Reply
#3

Fixed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)