trouble with map icons
#1

I want the server to show 2 global map icons whenever a player enters a certain vehicle(export system)
and then I want the server to remove them map icons as soon as the player exits that vehicle.

I almost had it working, except there was 1 problem.

Whenever I exited the vehicle, both the global map icons would disappear, which is good,
but then another random map icon in range of me would disappear, eg (ammunation icon) etc.

First off, I use streamer map icons. But for these 2 global map icons, i used SetPlayerMapIcon.

could they be interfering with each other? (i have around 170 streamer map icons)

here are some snippets of my code:

PHP код:
    if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
     {
         
RemovePlayerMapIcon(playerid1); // export ls
         
RemovePlayerMapIcon(playerid2); // export sf
     

PHP код:
    if(GetVehicleModel(vehicleid) == 535)
    {
    if(
sold1 == 0//not sold
    
{
        
SetPlayerMapIcon(playerid12801.4045,-2348.7034,13.6276550MAPICON_GLOBAL ); // Export LS
        
SetPlayerMapIcon(playerid2, -1545.0740,128.1534,3.5547550MAPICON_GLOBAL ); // Export SF
        
GameTextForPlayer(playerid,"Slamvan",3000,1);
        
SendClientMessage(playeridLIME"You Can Sell This Vehicle for $5000 At any Export Crane!");
    }
    else if(
sold1 == 1// sold
    
{
        
GameTextForPlayer(playerid,"Slamvan",3000,1);
        
SendClientMessage(playeridRED"This Vehicle has already been Exported! Use /exlist to See the Current List.");
    }
    } 
Reply
#2

Mixing up streamer stuff and standard samp stuff (icons, objects, pickups, ...) is not recommended.

You can get weird behaviour such as you described, and you are limiting the streamer in it's capabilities at the same time, because the standard samp stuff occupies slots and leaves the streamer with less slots available to do it's work.

Either use standard samp functions, or use the streamer, not both at the same time.
Reply
#3

Credits to you. I am currently using your business and house system on my server .

Anywho, I'll stick to streamer but the thing is, I don't know how to show/hide a mapicon using the streamer format.

I know i can create one ongamemodeinit but the thing is, I want that map icon to be global, only appear when entering a certain vehicle and then I want it to dissappear when exiting the vehicle.

With setplayermapicon i can do it but then like you said, it conflicts with the streamer. How can I do it via imcognitos streamer?
Reply
#4

native CreateDynamicMapIcon(Float, Float:y, Float:z, type, color, worldid = -1, interiorid = -1, playerid = -1, Floattreamdistance = 100.0, style = MAPICON_LOCAL);

Taken from the streamer topic.
That function takes a playerid parameter and is -1 by default and means it is created for all players.
If you supply a specific playerid, it will only be visible to that player only.
You can store the ID of that icon in the player's account, so you can destroy it afterwards when he leaves the vehicle using DestroyDynamicMapIcon.

Pseudo-code:
pawn Код:
OnPlayerEnterVehicle(playerid, vehicleid)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if (vehicleid == YourSpecialVehicle)
    {
        APlayerData[playerid][YourPrivateIcon] = CreateDynamicMapIcon(x, y, z, type, color, -1, -1, playerid, 100.0, MAPICON_GLOBAL);
    }

    return 1;
}

OnPlayerExitVehicle(playerid, vehicleid)
{
    if (vehicleid == YourSpecialVehicle)
    {
        DestroyDynamicMapIcon(APlayerData[playerid][YourPrivateIcon]);
        APlayerData[playerid][YourPrivateIcon] = 0;
    }

    return 1;
}
Reply
#5

Thanks for that. I'll give it a try when I have time, I'll reply here if it works.
Reply
#6

okay, i had to tweak it around a bit but it's working perfect now, thank you very much .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)