1 Error Need Help
#1

Код:
C:\Users\Matt\Desktop\SAMP\unitedgaming.pwn(23677) : error 021: symbol already defined: "OnPlayerStateChange"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
this is the line

Код:
public OnPlayerStateChange (playerid,newstate,oldstate)
{
	if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
	{
		TextDrawShowForPlayer(playerid, Textdraw0);
		TextDrawShowForPlayer(playerid, Textdraw1);
		TextDrawShowForPlayer(playerid, Textdraw2);
		TextDrawShowForPlayer(playerid, Textdraw3);
		TextDrawShowForPlayer(playerid, Textdraw4);
	}
	else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
	{
		TextDrawHideForPlayer(playerid, Textdraw0);
		TextDrawHideForPlayer(playerid, Textdraw1);
		TextDrawHideForPlayer(playerid, Textdraw2);
		TextDrawHideForPlayer(playerid, Textdraw3);
		TextDrawHideForPlayer(playerid, Textdraw4);
	}
	return 1;
}
Reply
#2

You've (probably) got the callback "OnPlayerStateChange" twice on your script.
Reply
#3

Quote:
Originally Posted by PrivatioBoni
Посмотреть сообщение
You've (probably) got the callback "OnPlayerStateChange" twice on your script.
but when i delete one of "OnPlayerStateChange" the error is increasing
Reply
#4

That's normal.
I believe Pawno prioritises some errors. If you have the same callback twice, that's what it'll tell you. When you fix that, you'll get the errors that were there before, but now it's just telling you about it.
Reply
#5

Do you have 2 OnPlayerStateChange ?
Reply
#6

Quote:
Originally Posted by Rittik
Посмотреть сообщение
Do you have 2 OnPlayerStateChange ?
yes

Here's what happen

Код:
C:\Users\Matt\Desktop\SAMP\unitedgaming.pwn(23672) : error 001: expected token: "-identifier-", but found "("
C:\Users\Matt\Desktop\SAMP\unitedgaming.pwn(23674) : error 010: invalid function or declaration
C:\Users\Matt\Desktop\SAMP\unitedgaming.pwn(23682) : error 010: invalid function or declaration
C:\Users\Matt\Desktop\SAMP\unitedgaming.pwn(23690) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
im adding filterscript to gamemode script
Reply
#7

Show us the full code.
Reply
#8

Quote:
Originally Posted by Rittik
Посмотреть сообщение
Show us the full code.
Код:
public OnPlayerStateChange (playerid, newstate, oldstate)
{
	if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
	{
		TextDrawShowForPlayer(playerid, Textdraw0);
		TextDrawShowForPlayer(playerid, Textdraw1);
		TextDrawShowForPlayer(playerid, Textdraw2);
		TextDrawShowForPlayer(playerid, Textdraw3);
		TextDrawShowForPlayer(playerid, Textdraw4);
	}
	else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
	{
		TextDrawHideForPlayer(playerid, Textdraw0);
		TextDrawHideForPlayer(playerid, Textdraw1);
		TextDrawHideForPlayer(playerid, Textdraw2);
		TextDrawHideForPlayer(playerid, Textdraw3);
		TextDrawHideForPlayer(playerid, Textdraw4);
	}
	return 1;
}
Reply
#9

The second OnPlayerStateChange
Reply
#10

Quote:
Originally Posted by Rittik
Посмотреть сообщение
The second OnPlayerStateChange
Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
	// Setup local variables
	new vid, Name[24], Msg[128], engine, lights, alarm, doors, bonnet, boot, objective;

	switch (newstate)
	{
		case PLAYER_STATE_DRIVER: // Player became the driver of a vehicle
		{
			// Get the ID of the player's vehicle
			vid = GetPlayerVehicleID(playerid);
			// Get the player's name (the one who is trying to enter the vehicle)
			GetPlayerName(playerid, Name, sizeof(Name));

			// Check if the vehicle is owned
			if (AVehicleData[vid][Owned] == true)
			{
				// Check if the vehicle is owned by somebody else (strcmp will not be 0)
				if (strcmp(AVehicleData[vid][Owner], Name, false) != 0)
				{
					// Force the player out of the vehicle
					RemovePlayerFromVehicle(playerid);
					// Turn off the lights and engine
					GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
					SetVehicleParamsEx(vid, 0, 0, alarm, doors, bonnet, boot, objective);
					// Let the player know he cannot use somebody else's vehicle
					format(Msg, 128, TXT_SpeedometerCannotUseVehicle, AVehicleData[vid][Owner]);
					SendClientMessage(playerid, 0xFFFFFFFF, Msg);
				}

				// Check if the vehicle is clamped
				if (AVehicleData[vid][Clamped] == true)
				{
					// Force the player out of the vehicle
					RemovePlayerFromVehicle(playerid);
					// Turn off the lights and engine
					GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
					SetVehicleParamsEx(vid, 0, 0, alarm, doors, bonnet, boot, objective);
					// Let the player know he cannot use a clamped vehicle
					format(Msg, 128, TXT_SpeedometerClampedVehicle);
					SendClientMessage(playerid, 0xFFFFFFFF, Msg);
					format(Msg, 128, TXT_SpeedometerClampedVehicle2);
					SendClientMessage(playerid, 0xFFFFFFFF, Msg);
				}
			}

			// Check if the player is not a cop
			if (PInfo[playerid][PlayerClass] != ClassPolice)
			{
				// First check if the vehicle is a static vehicle (player can still use a bought cop-car that he bought in his house,
				// as a bought vehicle isn't static)
				if (AVehicleData[vid][StaticVehicle] == true)
				{
					// Check if the entered vehicle is a cop vehicle
					switch (GetVehicleModel(vid))
					{
						case VehiclePoliceLSPD, VehiclePoliceSFPD, VehiclePoliceLVPD, VehicleHPV1000, VehiclePoliceRanger:
						{
							// Force the player out of the vehicle
							RemovePlayerFromVehicle(playerid);
							// Turn off the lights and engine
							GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
							SetVehicleParamsEx(vid, 0, 0, alarm, doors, bonnet, boot, objective);
							// Let the player know he cannot use a cop car
							SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot use a police vehicle");
						}
					}
				}
			}

			// Check if the player is not a pilot
			if (PInfo[playerid][PlayerClass] != ClassPilot)
			{
				// First check if the vehicle is a static vehicle (player can still use a bought plane that he bought in his house,
				// as a bought vehicle isn't static)
				if (AVehicleData[vid][StaticVehicle] == true)
				{
					// Check if the entered vehicle is a plane or helicopter vehicle
					switch (GetVehicleModel(vid))
					{
						case VehicleShamal, VehicleNevada, VehicleStuntPlane, VehicleDodo, VehicleMaverick, VehicleCargobob:
						{
							// Force the player out of the vehicle
							RemovePlayerFromVehicle(playerid);
							// Turn off the lights and engine
							GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
							SetVehicleParamsEx(vid, 0, 0, alarm, doors, bonnet, boot, objective);
							// Let the player know he cannot use a cop car
							SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot use a pilot vehicle");
						}
					}
				}
			}
		}
	}

	return 1;
}

// This callback gets called whenever a player presses a key
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	// Debug the keypresses
//	DebugKeys(playerid, newkeys, oldkeys);

	// ****************************************************************************************
	// NOTE: the keys are messed up, so the code may look strange when testing for certain keys
	// ****************************************************************************************

	// Fining and jailing players when you're police and press the correct keys
	// Check the class of the player
	switch (PInfo[playerid][PlayerClass])
	{
		case ClassPolice:
		{
		    // If the police-player pressed the RMB key (AIM key) when OUTSIDE his vehicle
			if (((newkeys & KEY_HANDBRAKE) && !(oldkeys & KEY_HANDBRAKE)) && (GetPlayerVehicleID(playerid) == 0))
				Police_FineNearbyPlayers(playerid);

		    // If the police-player pressed the LCTRL (SECUNDAIRY key) key when INSIDE his vehicle
			if (((newkeys & KEY_ACTION) && !(oldkeys & KEY_ACTION)) && (GetPlayerVehicleID(playerid) != 0))
				Police_WarnNearbyPlayers(playerid);
		}
		case ClassAssistance:
		{
		    // If the assistance-player pressed the RMB key (AIM key) when OUTSIDE his vehicle
			if (((newkeys & KEY_HANDBRAKE) && !(oldkeys & KEY_HANDBRAKE)) && (GetPlayerVehicleID(playerid) == 0))
				Assistance_FixVehicle(playerid);

		    // If the police-player pressed the LCTRL (SECUNDAIRY key) key when INSIDE his vehicle
			if (((newkeys & KEY_ACTION) && !(oldkeys & KEY_ACTION)) && (GetPlayerVehicleID(playerid) != 0))
				Assistance_FixOwnVehicle(playerid);
		}
	}

	// Trying to attach the closest vehicle to the towtruck when the player pressed FIRE when inside a towtruck
	// Check if the player is inside a towtruck
	if(GetVehicleModel(GetPlayerVehicleID(playerid)) == VehicleTowTruck)
	{
		// Check if the player pushed the fire-key
		if(newkeys & KEY_FIRE)
		{
			// Get the vehicle-id of the closest vehicle
			new closest = GetClosestVehicle(playerid);
			if(VehicleToPlayer(playerid, closest) < 10) // Check if the closest vehicle is within 10m from the player
				AttachTrailerToVehicle(closest, GetPlayerVehicleID(playerid)); // Attach the vehicle to the towtruck
		}
	}

	// Refuel a vehicle when driving a vehicle and pressing the HORN key
	// Check if the player presses the HORN key
	if ((newkeys & KEY_CROUCH) && !(oldkeys & KEY_CROUCH))
	{
		// Check if the player is driving a vehicle
		if (GetPlayerVehicleSeat(playerid) == 0)
		{
			// Loop through all ARefuelPickups
			for (new i; i < sizeof(ARefuelPickups); i++)
			{
				// Check if the player is in range of a refuelpickup
				if(IsPlayerInRangeOfPoint(playerid, 2.5, ARefuelPickups[i][pux], ARefuelPickups[i][puy], ARefuelPickups[i][puz]))
				{
					// Show a message that the player's vehicle is refuelling
					GameTextForPlayer(playerid, TXT_Refuelling, 3000, 4);
					// Don't allow the player to move again (the timer will allow it after refuelling)
					TogglePlayerControllable(playerid, 0);
				       // Start a timer (let the player wait until the vehicle is refuelled)
				    SetTimerEx("RefuelVehicle", 5000, false, "i", playerid);
				    // Stop the search
					break;
				}
			}
		}
	}

	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)