"GetNearest" problem with pickup
#1

[ UPDATED ]
The problem caused before has been fixed. However, my timer seems to multiply each time by x2. If I wait till my function does its job, every 3 secs it would look like that:
First 3 secs - function done
3 secs more - 2x(function done)
3 secs more - 3x(functions done)


This is another problem I have. It seems as it duplicates each time. May someone help?

Hello everyone,
I got a little problem with my script at the part where it is meant to find a vehicle nearby the player (the script is set to look at the range of 20 around the player). However, I get the opposite outcome (doesn't find the vehicle) even when the vehicle is nearby the player.

I'm using this include: https://sampforum.blast.hk/showthread.php?tid=321575

This is the script and hope you can help:
Код:
if(pickupid > Degaline[0]-1 && pickupid < Degaline[1]+1)
	{
	        new ArYraMasina = GetNearest(playerid, VEHICLE, 20.0);
	        if(ArYraMasina != 0)
	        {
	        SendClientMessage(playerid,RAUDONA,"Kur jыsш tr.priemonл?");
		}
		else
		{
		    SetTimerEx("PilasiDegalai", 3000, true, "i", playerid);
		}
		return 1;
	}
The actual timer (if you notice extra-mistake):
Код:
forward PilasiDegalai(playerid);
public PilasiDegalai(playerid)
{
	new ArYraMasina = GetNearest(playerid, VEHICLE, 20.0);
    if(VehOwned[ArYraMasina] == 1)
    {
        SetPVarInt(playerid,"PilasiDegalus",1);
    	new file[150], owner[24], string[128];
    	GetPlayerName(OwnerID[ArYraMasina], owner, sizeof(owner));
    	format(file,sizeof(file),"TransportoPr/%s.ini",owner);
    	dini_FloatSet(file,"Degalai",dini_Float(file,"Degalai")+1);
    	GivePlayerMoney(playerid,-2);
    	SetTimerEx("PilasiDegalai", 3000, true, "i", playerid);
		format(string,sizeof(string),"Бpilta 1 litras б nuosavа maрinа, dabartinis degalш kiekis: %.3f",dini_Float(file,"Degalai"));
		SendClientMessage(playerid,MELYNA,string);
		TogglePlayerControllable(playerid,0);
	}
	else
	{
	    SetPVarInt(playerid,"PilasiDegalus",1);
	    new string2[128];
		degalai[ArYraMasina] = degalai[ArYraMasina] +1;
		GivePlayerMoney(playerid,-2);
		SetTimerEx("PilasiDegalai", 3000, true, "i", playerid);
		format(string2,sizeof(string2),"Бpilta 1 litras, dabartinis degalш kiekis: %.3f",degalai[ArYraMasina]);
		SendClientMessage(playerid,MELYNA,string2);
		TogglePlayerControllable(playerid,0);
	}
	return 1;
}
Main problem is I get the wrong outcome at this part:
Код:
if(ArYraMasina != 0)
	        {
	        SendClientMessage(playerid,RAUDONA,"Kur jыsш tr.priemonл?");
		}
I get this outcome:
Код:
SendClientMessage(playerid,RAUDONA,"Kur jыsш tr.priemonл?");
Instead of starting the actual timer which IS WHAT I NEED.

I'd appreciate any help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)