SA-MP Forums Archive
Problems with Playerid 0 - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problems with Playerid 0 (/showthread.php?tid=66024)



Problems with Playerid 0 - modmk - 18.02.2009

Hey Guys,

it's me again :P
I found some new problems in my script...
As soon as I got more than one player on my server, some bugs with playerid 0 appear. for example the /lock function or my fuelscript wouldn't work properly. But ONLY if there is more than on player online and only ID 0...

Could this be a samp bug or do i have to put something in my script to solve this problem?

thanks, modmk

PS: it's not only one or two things but almost every single function that exists...


Re: Problems with Playerid 0 - Nero_3D - 18.02.2009

maybe you did it like that
pawn Код:
function()
{
    new playerid;
    SetPlayerHealth(playerid, 100.0);
}
this function will always only set the health from playerid 0 to 100 :S

Ok we cant say whats the problem is, we need something like a part of your code where that happens
maybe we can see than the problem, without code we just can guess


Re: Problems with Playerid 0 - Rks25 - 18.02.2009

It is also possible you are doing:
pawn Код:
SetTimer("Tester",1000,1);

public Tester(playerid)
[
  SetPlayerHealth(playerid, 100.0);
}



Re: Problems with Playerid 0 - modmk - 19.02.2009

for example this script:

Код:
public UpdateSpeed(playerid)                              //Speedo + Benzin
{
	new Text:vehht;
	TextDrawDestroy(Text:vehht);
	new Float:x,Float:y,Float:z;
	new Float:distance,value,string[128];
	new Float:health;
	new vehid;
	for(new i=0; i<MAX_PLAYERS; i++)  //SLOTS
	{
		if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
		{
			TextDrawDestroy(Speedo[i]);
		}
	}
	for(new i=0; i<MAX_PLAYERS; i++)     //SLOTS
	{
		if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
		{
		  vehid = GetPlayerVehicleID(i);
			format(string, sizeof(string),"cars/car%d.ini",vehid);
			GetPlayerPos(i, x, y, z);
			GetVehicleHealth(GetPlayerVehicleID(i), health);
			distance = floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[i][LastX])),2)+floatpower(floatabs(floatsub(y,SavePlayerPos[i][LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[i][LastZ])),2));
			value = floatround(distance * 5000);
			if(UpdateSeconds > 1)
			{
				value = floatround(value / UpdateSeconds);
			}
			format(string,sizeof(string),"~l~Fahrzeug: ~w~%s ~n~~l~km/h: ~w~%d ~n~~l~FahrzeugHP: ~w~ %.2f ~n~~l~Benzin: ~w~%d ~n~~l~VehID: ~w~%d",CarName[GetVehicleModel(GetPlayerVehicleID(i))-400], floatround(value/1000), health, Gas[vehid], vehid);
			Speedo[i] = TextDrawCreate(380.00, 380.00, string);
			TextDrawSetOutline(Speedo[i], 0);
			TextDrawFont(Speedo[i], 1);
			TextDrawSetShadow(Speedo[i], 0);
			TextDrawSetProportional(Speedo[i], 2);
			TextDrawAlignment(Speedo[i], 2);
			TextDrawShowForPlayer (i, Speedo[i]);
		}
		SavePlayerPos[i][LastX] = x;
		SavePlayerPos[i][LastY] = y;
		SavePlayerPos[i][LastZ] = z;
		if(IsPlayerInAnyVehicle(i))
		{
			if(Gas[vehid] < 1)
			{
		  	NoFuel[playerid] = 1;
		  	TogglePlayerControllable(i, 0);
		  	GameTextForPlayer(i,"~w~~n~~n~~n~~n~~n~~n~~n~~n~Kein Benzin mehr im Tank~n~Nutze /exitcar zum Aussteigen",1500,3);
			}
		}
	}
}
as i said, the function works for everybody except for ID 0....
and not only this function.


Re: Problems with Playerid 0 - Toxicity - 19.02.2009

Try changing the < to <=

Код:
for(new i=0; i<MAX_PLAYERS; i++)
...becomes:
Код:
for(new i=0; i<=MAX_PLAYERS; i++)



Re: Problems with Playerid 0 - yom - 19.02.2009

Don't try/use Toxicity's suggestion, it will make your script crash.


Re: Problems with Playerid 0 - modmk - 19.02.2009

Quote:
Originally Posted by 0rb
Don't try/use Toxicity's suggestion, it will make your script crash.
i know, cause it'll count more one more than the maximum player count...


Re: Problems with Playerid 0 - yom - 19.02.2009

With how many players have you tested this, to confirm it works for everyone but id 0 ? I suggest you show your whole script (on pastebin, not here).


Re: Problems with Playerid 0 - modmk - 23.02.2009

Quote:
Originally Posted by 0rb
With how many players have you tested this, to confirm it works for everyone but id 0 ? I suggest you show your whole script (on pastebin, not here).
well, my script has more than 8000 lines, i don't think anybody would want to check all that...
but to confirm my problem, i tested it with about 10-15 players. and all the time its only ID 0 that has problems....