Money on pirate ship SOLVED
#1

Hey guys. I want that when you are on the priate ship in LV you get money. Now I have this:
I want that it comes every 3 seconds when you stand there


if(IsPlayerInRangeOfPoint(playerid, 20.0, 2000.6755,1543.2694,13.5859))
{
SetTimer("ShipEarn", 3000, true);
GivePlayerMoney(playerid,50);


It just keeps coming so fast.


Reply
#2

pawn Код:
public OnPlayerSpawn(playerid)
{
  SetTimer("CheckShip", 1000, true);
  return 1;
}

forward CheckShip(playerid);
public CheckShip(playerid)
{
  if(IsPlayerInRangeOfPoint(playerid, 20.0, 2000.6755,1543.2694,13.5859))
  {
    SetTimer("ShipEarn", 3000, true);
  }
  return 1;
}

forward ShipEarn(playerid);
public ShipEarn(playerid)
{
  GivePlayerMoney(playerid, 50);
  return 1;
}
Reply
#3

iam sure you know where to put these parts in...
Код:
	SetTimer("TimerPirateShip",3000,true);
Код:
forward TimerPirateShip();
public TimerPirateShip()
{
	new ID;
	for(ID=0;ID<MAX_PLAYERS;ID++)
	{
		if(IsPlayerInRangeOfPoint(ID, 20.0, 2000.6755,1543.2694,13.5859))
		{
			GivePlayerMoney(playerid,50);
		}
	}
}
Reply
#4

Quote:
Originally Posted by Babul
iam sure you know where to put these parts in...
Код:
	SetTimer("TimerPirateShip",3000,true);
Код:
forward TimerPirateShip();
public TimerPirateShip()
{
	new ID;
	for(ID=0;ID<MAX_PLAYERS;ID++)
	{
		if(IsPlayerInRangeOfPoint(ID, 20.0, 2000.6755,1543.2694,13.5859))
		{
			GivePlayerMoney(playerid,50);
		}
	}
}
Wrong, that would give: Error undefined symbol "playerid"
Use my code, it will work

@Babul
Btw i suggest using this loop instead of yours as it is faster.

pawn Код:
for(new i=0; i<MAX_PLAYERS; i++)
Just change your "ID" to "i"
Reply
#5

Quote:
Originally Posted by [NWA
Hannes ]
Quote:
Originally Posted by Babul
iam sure you know where to put these parts in...
Код:
	SetTimer("TimerPirateShip",3000,true);
Код:
forward TimerPirateShip();
public TimerPirateShip()
{
	new ID;
	for(ID=0;ID<MAX_PLAYERS;ID++)
	{
		if(IsPlayerInRangeOfPoint(ID, 20.0, 2000.6755,1543.2694,13.5859))
		{
			GivePlayerMoney(playerid,50);
		}
	}
}
Wrong, that would give: Error undefined symbol "playerid"
Use my code, it will work

@Babul
Btw i suggest using this loop instead of yours as it is faster.

pawn Код:
for(new i=0; i<MAX_PLAYERS; i++)
Just change your "ID" to "i"
Your code wouldn't work either, https://sampwiki.blast.hk/wiki/SetTimerEx.

Babul was closer than you where. Your code would make countless timers that would add up and add up because you don't kill them in anyway. Also, you set the timer for ship earn that continues. So, if you are not in the area you will still get $$. Babuls was a simple mistake, yours wasn't. Here is the proper code.

pawn Код:
SetTimer("TimerPirateShip",3000,true);

forward TimerPirateShip();
public TimerPirateShip()
{
    new ID;
    for(ID=0;ID<MAX_PLAYERS;ID++)
    {
        if(IsPlayerInRangeOfPoint(ID, 20.0, 2000.6755,1543.2694,13.5859))
        {
            GivePlayerMoney(ID,50);
        }
    }
}
P.S. How is "i" faster than "ID", it would take around half a second longer, it doesn't need to be changed.
Reply
#6

oops, the playerid needs to be replaced by ID of course, lol..
i also forgot to use the GetMaxPlayers() (will return the server.cfg settings) instead of just MAX_PLAYERS, as most servers dont host 500 slots (MAX_PLAYERS=500, yeah), this will decrease the loop a bit
Код:
	SetTimer("TimerPirateShip",3000,true);
Код:
forward TimerPirateShip();
public TimerPirateShip()
{
	new ID,MaxPlayers;
	MaxPlayers=GetMaxPlayers();
	for(ID=0;ID<MaxPlayers;ID++)
	{
		if(IsPlayerInRangeOfPoint(ID, 20.0, 2000.6755,1543.2694,13.5859))
		{
			GivePlayerMoney(ID,50);
		}
	}
}
Reply
#7

Thanks for helping but at hannes his script it only works a bit. When I walk off the ship it is still addiing money. And it only works the first phew seconds, after 30 seconds or something it is going fast.


The other scripts doesn't work, No effect.

please help osomeone
Reply
#8

Might not work, but might work at the same time
Try it
pawn Код:
//Above main
new GiveTimer;

public OnPlayerSpawn(playerid)
{
  SetTimer("CheckShip", 1000, true);
  return 1;
}

forward CheckShip(playerid);
public CheckShip(playerid)
{
  if(IsPlayerInRangeOfPoint(playerid, 20.0, 2000.6755,1543.2694,13.5859))
  {
    GiveTimer = SetTimer("ShipEarn", 3000, true);
  }
  else
  {
    KillTimer(GiveTimer);
  }
  return 1;
}

forward ShipEarn(playerid);
public ShipEarn(playerid)
{
  GivePlayerMoney(playerid, 50);
  return 1;
}
Reply
#9

still doesn't work. When I walk off the ship it is still giving money :O
Reply
#10

Код:
 forward PirateShip();//on top
Код:
SetTimer("PirateShip", 3000, true); // ongamemodeinit/OnFilterscriptInit
Код:
public PirateShip()// new callback
{
	for(new i = 0; i<MAX_PLAYERS; i++)
	{
	  if(IsPlayerInRangeOfPoint(i, 20, 2000.6755,1543.2694,13.5859))
	  {
	    GivePlayerMoney(i, 50);
		}
	}
}
I hope this works.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)