Automatic Gate opens only for users with an id of 0
#1

Automatic Gate opens (works) only for users with an id of 0 no matter if others are admins or work in that job. I dont know why is that

I put this

Код:
SetTimer("GateTimer", 3000, true);
under
Код:
public OnGameModeInit()
{
Then i put this

Код:
public GateTimer(playerid)
{

if(playerDB[playerid][specialybe]==1 || playerDB[playerid][admin])
if(IsPlayerInRangeOfPoint(playerid, 15, -1631.78, 688.24, 8.6))
{
MoveObject(SFPDshutter, -1631.78, 688.24, 14.68,2);
}
if(playerDB[playerid][specialybe]==1 || playerDB[playerid][admin])
if(IsPlayerInRangeOfPoint(playerid, 15, -1641.391602, 680.608826, 8.073167))
{
MoveObject(SFPDgate, -1641.385742, 687.582703, 8.124618,2);
}
if(playerDB[playerid][specialybe]==1 || playerDB[playerid][admin])
if(IsPlayerInRangeOfPoint(playerid, 15, -1571.862183, 663.180664, 7.998168))
{
MoveObject(SFPDgate1, -1571.873047, 668.873352, 7.974930,2);
}
if(playerDB[playerid][vip] || playerDB[playerid][admin])
if(IsPlayerInRangeOfPoint(playerid, 15, -2079.0961914063, 1366.5452880859, 8.8740577697754))
{
MoveObject(vipv, -2079.0961914063, 1366.5452880859, 0.8740577697754,3);
}
if(playerDB[playerid][specialybe]==52 || playerDB[playerid][admin])
if(IsPlayerInRangeOfPoint(playerid, 15, -2433.755859375, 496.25634765625, 31.701829910278))
{
MoveObject(apv, -2433.755859375, 496.25634765625, 23.701829910278,3);
}
if(playerDB[playerid][specialybe]==10 || playerDB[playerid][admin])
if(IsPlayerInRangeOfPoint(playerid, 15, -1039.1740722656, -586.90856933594, 33.781204223633))
{
MoveObject(armijav, -1039.1740722656, -586.90856933594, 25.781204223633,2);
}
if(playerDB[playerid][specialybe]==56 || playerDB[playerid][admin])
if(IsPlayerInRangeOfPoint(playerid, 15, -715.131,969.447,13.914))
{
MoveObject(zydrag, -715.127,969.430,8.109,2);
}
if(playerDB[playerid][specialybe]==55 || playerDB[playerid][admin])
if(IsPlayerInRangeOfPoint(playerid, 15, -2486.223,-614.577,134.288))
{
MoveObject(ballas, -2486.223,-614.573,128.361,2);
}
if(playerDB[playerid][specialybe]==10 || playerDB[playerid][admin])
if(IsPlayerInRangeOfPoint(playerid, 15, -1531.3148193359, 482.1376953125, 8.9608917236328))
{
MoveObject(fbiv, -1531.3148193359, 482.1376953125, 0.9608917236328,2);
}
return 1;
}
In the back of the gamemode. Help please
Reply
#2

You call timer without playerid parameter that's why it's assumed 0. Instead try calling timer without any parameters and loop through players within the timer.
Reply
#3

Код:
public GateTimer()
{
	for(new playerid;playerid<MAX_PLAYERS;playerid++)
	{
		if(playerDB[playerid][specialybe]==1 || playerDB[playerid][admin])
		if(IsPlayerInRangeOfPoint(playerid, 15, -1631.78, 688.24, 8.6))
		{
		MoveObject(SFPDshutter, -1631.78, 688.24, 14.68,2);
		}
		if(playerDB[playerid][specialybe]==1 || playerDB[playerid][admin])
		if(IsPlayerInRangeOfPoint(playerid, 15, -1641.391602, 680.608826, 8.073167))
		{
		MoveObject(SFPDgate, -1641.385742, 687.582703, 8.124618,2);
		}
		if(playerDB[playerid][specialybe]==1 || playerDB[playerid][admin])
		if(IsPlayerInRangeOfPoint(playerid, 15, -1571.862183, 663.180664, 7.998168))
		{
		MoveObject(SFPDgate1, -1571.873047, 668.873352, 7.974930,2);
		}
		if(playerDB[playerid][vip] || playerDB[playerid][admin])
		if(IsPlayerInRangeOfPoint(playerid, 15, -2079.0961914063, 1366.5452880859, 8.8740577697754))
		{
		MoveObject(vipv, -2079.0961914063, 1366.5452880859, 0.8740577697754,3);
		}
		if(playerDB[playerid][specialybe]==52 || playerDB[playerid][admin])
		if(IsPlayerInRangeOfPoint(playerid, 15, -2433.755859375, 496.25634765625, 31.701829910278))
		{
		MoveObject(apv, -2433.755859375, 496.25634765625, 23.701829910278,3);
		}
		if(playerDB[playerid][specialybe]==10 || playerDB[playerid][admin])
		if(IsPlayerInRangeOfPoint(playerid, 15, -1039.1740722656, -586.90856933594, 33.781204223633))
		{
		MoveObject(armijav, -1039.1740722656, -586.90856933594, 25.781204223633,2);
		}
		if(playerDB[playerid][specialybe]==56 || playerDB[playerid][admin])
		if(IsPlayerInRangeOfPoint(playerid, 15, -715.131,969.447,13.914))
		{
		MoveObject(zydrag, -715.127,969.430,8.109,2);
		}
		if(playerDB[playerid][specialybe]==55 || playerDB[playerid][admin])
		if(IsPlayerInRangeOfPoint(playerid, 15, -2486.223,-614.577,134.288))
		{
		MoveObject(ballas, -2486.223,-614.573,128.361,2);
		}
		if(playerDB[playerid][specialybe]==10 || playerDB[playerid][admin])
		if(IsPlayerInRangeOfPoint(playerid, 15, -1531.3148193359, 482.1376953125, 8.9608917236328))
		{
		MoveObject(fbiv, -1531.3148193359, 482.1376953125, 0.9608917236328,2);
		}
	}
	return 1;
}
Reply
#4

I'd rather use SetTimerEx under OnPlayerConnect. Should yield much better result. Otherwise.. with 100 players that function could be as slow as fck as it doesn't and in this way it can't just return 1/0; in end of action.
Reply
#5

Yes, SetTimerEx works for playerid, and SetTimer works only for ID 0

so :
pawn Код:
SetTimerEx("GateTimer", 3000, true, "i", playerid);
Reply
#6

Quote:
Originally Posted by Mean
Посмотреть сообщение
Yes, SetTimerEx works for playerid, and SetTimer works only for ID 0

so :
pawn Код:
SetTimerEx("GateTimer", 3000, true, "i", playerid);
I added this under an other timer and:

Код:
data/init.txt(472) : error 017: undefined symbol "playerid"
Reply
#7

Don't add it under the timer, replace it with the old timer. + YOu need to add it somewhere in a function, example:

pawn Код:
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
    SetTimerEx("GateTimer", 3000, true, "i", playerid);
    return 1;
}
Reply
#8

But i want to make automatic gates without commands.
Reply
#9

Add at OnPlayerUpdate

pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 20, x, y, z)) // Replace 20 with the desired range. Replace x, y, z with the coordinates of your gate.
{
       SetTimerEx("GateTimer", 3000, true, "i", playerid);
       return 1;
}
Reply
#10

If i have a few points can i do this?

Код:
if(IsPlayerInRangeOfPoint(playerid, 20, x, y, z))
else if(IsPlayerInRangeOfPoint(playerid, 20, x, y, z))
else if(IsPlayerInRangeOfPoint(playerid, 20, x, y, z))
else if(IsPlayerInRangeOfPoint(playerid, 20, x, y, z))
{
       SetTimerEx("GateTimer", 3000, true, "i", playerid);
       return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)