[HELP] simple plz help
#1

Since my title now lured you into this thread, please take some time to answer..

I have a problem of Callbacks not calling in my filterscripts if they are in use by the main gamemode. The 2 callbacks seem to collide somehow and the code get's messed up.

Let me show you an example:

Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
	if ((newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER))
	{
		new
		    vid;
		vid = GetPlayerVehicleID(playerid);
		for(new i=0; i<9; i++)
		{
		    if(vid == DMGcars[i])
		    {
		        TogglePlayerControllable(playerid, 0);
		        GameTextForPlayer(playerid, "~r~This car is to badly damaged! Press ~k~~VEHICLE_ENTER_EXIT~ to exit.", 3000, 5);
		        indamagedcar[playerid]=1;
			}
		}
	}
	return 1;
}
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        new vid = GetPlayerVehicleID(playerid);
        if(VehicleFuel[vid] > 20)
        {
        	new
				fstring[128];
			format(fstring,sizeof fstring,"~w~Fuel: ~g~%i%%",VehicleFuel[vid]);
			TextDrawSetString(Textdraw0[playerid],fstring);
        	TextDrawShowForPlayer(playerid,Textdraw0[playerid]);
		}
		else if(VehicleFuel[vid] <= 20)
		{
		    new
				fstring[125];
			format(fstring,sizeof fstring,"~w~Fuel: ~r~%i%%",VehicleFuel[vid]);

			TextDrawSetString(Textdraw0[playerid],fstring);
        	TextDrawShowForPlayer(playerid,Textdraw0[playerid]);
		}
	}
	else
	{
		TextDrawHideForPlayer(playerid,Textdraw0[playerid]); //hiding if a player isnt driving/or an passenger
 	}
    return 1;
}
Instead of showing the fuel for ALL the cars, it only shows the fuel for the damaged cars. How do I fix this?
Reply
#2

i cant see the problem in this code, but i do see that you try to make a player uncontrollable and then ask them to exit the vehicle
Reply
#3

Okay apparently sa-mp doesn't like calling OnPlayerSpawn in FS and by debugging with print I managed to find that the problem was caused by ABSOLUTELY NOTHING and the only fix was moving it to my main gamemode.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)