How to make this work?
#1

Код:
public Tanker(playerid)// new callback
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid;
if(GetVehicleModel(vehicleid)==tanker)
if(GetVehicleModel(vehicleid)==tankertrailer)
{
CreateMapIcon(51, 0, X, Y, Z);
}
return 1;
}
return 1;
}
What i want that to do, is make a map icon on the tankertrailer's position, and when it moves, it follows it. I think this is only possible if you create, destroy, create, destroy etc etc, how would i do this? (i use Double-O-Icons) I want it to create the map icon when the gamemode starts. and then destroy that one and create a new one when someone gets in, and then i want it to follow the tanker trailer when somebody enters the tanker.
Reply
#2

Код:
public Tanker(playerid)// new callback
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid;
if(GetVehicleModel(vehicleid)==tanker)
if(GetVehicleModel(vehicleid)==tankertrailer)
{
new Float:vehx, Float:vehy, Float:vehz;
GetVehiclePos(tankertrailer, vehx, vehy, vehz);
CreateMapIcon(51, 0, vehx, vehy, vehz);
}
return 1;
}
return 1;
}
Updated code, now how do i make it destroy the icon and create a new on every few seconds?
Reply
#3

Sorry for loads of posting but

Код:
public Tanker(playerid)// new callback
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid;
if(GetVehicleModel(vehicleid)==tanker)
if(GetVehicleModel(vehicleid)==tankertrailer)
{
new Float:vehx, Float:vehy, Float:vehz;
GetVehiclePos(tankertrailer, vehx, vehy, vehz);
DestroyMapIcon(tankericon);
CreateMapIcon(51, 0, vehx, vehy, vehz);
}
return 1;
}
return 1;
}
Just need help making the code to make it destroy the new mapicon and create a new on every few seconds(timer?)
Reply
#4

make tankericon global. Then on timer

forward tankupdate();


under OnGamemodeInnit()

SetTimer("tankupdate",1000,1);

somewhere random

pawn Код:
public tankupdate()
{
   for(new i=0; i<MAX_PLAYERS; i++)
   if(IsPlayerInAnyVehicle(i))
   {
       if(GetPlayerVehicleModel(i) == Tankerids)
       {
          new Float:X,Float:Y,Float:Z,tankid;
          tankid = GetPlayerVehicleID(i);
          GetVehiclePos(tankid,X,Y,Z);
          DestroyMapIcon(tankericon);
          tankericon = CreateMapIcon(51,0,X,Y,Z);
          }
       }
    return 1;
}
Untested
Reply
#5

Thanks for the help, it doesn't seem to destroy the original and also it doesnt seem to create a new one
Reply
#6

OK, it seems that i have fixed it, but it only updates once, how do i make it keep it up to date - like so it carries on following?
Reply
#7

Damn, it doesn't work at all, i imagined it, any ideas how?
Reply
#8

Is this truck some kind of objective like steal it and bring it to somewhere?

Then you could do this which i think is easier

pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
   if(newstate == PLAYER_STATE_DRIVER)
   {
       if(GetPlayerVehicleModel(playerid) == truckid)
       {
          for(new i=0; i<MAX_PLAYERS; i++)
          {
              SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i,1,0);
              return 1;
              }
          }
       }
    return 1;
}
Else im out of ideas. Im not familiar with double-o's map icon streamer so im not sure if the need to use DestroyMapIcon some special way
Reply
#9

This is the DestroyMapIcon function (from double-o-icons include) forward DestroyMapIcon(id);
public DestroyMapIcon(id)
{
if(!IconActive[id]) return 0;

new slot;
IconActive[id]=false;
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
slot=IconSlot[i][id];
if(slot!=INVALID_SLOT)
{
RemovePlayerMapIcon(i,slot);
SlotIconID[i][slot]=INVALID_ICON_ID;
IconSlot[i][id]=INVALID_SLOT;
}
}
}
return 1;
}
Reply
#10

Код:
public tankupdate(playerid)
{
for(new i=0; i<MAX_PLAYERS; i++)
if(IsPlayerInAnyVehicle(i))
{
if(GetVehicleModel(i) == tanker)
{
new Float:X,Float:Y,Float:Z,tankid;
tankid = GetPlayerVehicleID(i);
GetVehiclePos(tankid,X,Y,Z);
RemovePlayerMapIcon(playerid, tankericon);
tankericon = SetPlayerMapIcon( playerid, 12, X, Y, Z, 51, 0);
}
}
return 1;
}
That is what im trying to do, it looks correct but doesn't work... How do i make it work?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)