SA-MP Forums Archive
property icon - 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)
+--- Thread: property icon (/showthread.php?tid=570336)



property icon - JeaSon - 09.04.2015

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;




Re: property icon - Vince - 09.04.2015

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


Re: property icon - JeaSon - 09.04.2015

Fixed