Need Help . lost weapon when out car ?
#1

Video : https://www.youtube.com/watch?v=_gBE...ature=*********
can u help me ?
Reply
#2

Show us onplayerstatechange ?
Reply
#3

Код HTML:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
	{
 		if(!IsPlayerEntering{playerid})
		{
			if(GetPVarInt(playerid, "TeleportWarnings") == 3) {
				new string[128];
		    	format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s (ID: %d) may have just teleported into a vehicle.", GetPlayerNameEx(playerid), playerid);
				ABroadCast(COLOR_YELLOW, string, 2);
				DeletePVar(playerid, "TeleportWarnings");
			}
			else
			{
			    SetPVarInt(playerid, "TeleportWarnings", GetPVarInt(playerid, "TeleportWarnings")+1);
			}
		}
		if (CarRadars[playerid] > 0)
		{
			PlayerTextDrawShow(playerid, _crTextTarget[playerid]);
			PlayerTextDrawShow(playerid, _crTextSpeed[playerid]);
			PlayerTextDrawShow(playerid, _crTickets[playerid]);
			DeletePVar(playerid, "_lastTicketWarning");
		}
	}
	IsPlayerEntering{playerid} = false;
	/*if(newstate == PLAYER_STATE_PASSENGER)
	{
		if (PlayerInfo[playerid][pSpeedo] != 0)
		{
			ShowVehicleHUDForPlayer(playerid);
		}
	}*/
	if(newstate == PLAYER_STATE_DRIVER)
	{
		if (IsAtGym(playerid))
		{
			new biz = InBusiness(playerid);
			new veh = GetPlayerVehicleID(playerid);

			for (new it = 0; it < 10; ++it)
			{
				if (Businesses[biz][bGymBikeVehicles][it] == veh)
				{
					if (GetPVarInt(playerid, "_BikeParkourSlot") != it)
					{
						RemovePlayerFromVehicle(playerid);
						SendClientMessageEx(playerid, COLOR_GRAD2, "That is not your bike!");
					}
				}
			}
		}

		/*if (PlayerInfo[playerid][pSpeedo] != 0)
		{
			ShowVehicleHUDForPlayer(playerid);
		}*/

	    new vehicleid = GetPlayerVehicleID(playerid);
		if(GetVehicleModel(vehicleid) == 530)
		{
		    if(CrateVehicleLoad[vehicleid][vForkLoaded])
		    {
			    new Float: pX, Float: pY, Float: pZ;
				GetPlayerPos(playerid, pX, pY, pZ);
				SetPVarFloat(playerid, "tpForkliftX", pX);
		 		SetPVarFloat(playerid, "tpForkliftY", pY);
		  		SetPVarFloat(playerid, "tpForkliftZ", pZ);
				SetPVarInt(playerid, "tpForkliftTimer", 80);
				SetPVarInt(playerid, "tpForkliftID", GetPlayerVehicleID(playerid));
				SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_CRATETIMER);
		    }
		}
	}
    if(newstate != 2) NOPTrigger[playerid] = 0;
	//Specating
	if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER || newstate == PLAYER_STATE_ONFOOT)
	{
		foreach(new i: Player) {
			if(PlayerInfo[i][pAdmin] >= 2 || GetPVarType(i, "pWatchdogWatching")) {
				if(Spectating[i] > 0 && Spectate[i] == playerid) {
					if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER) {
						TogglePlayerSpectating(i, true);
						new carid = GetPlayerVehicleID( playerid );
						PlayerSpectateVehicle( i, carid );
					}	
					else if(newstate == PLAYER_STATE_ONFOOT) {
						TogglePlayerSpectating(i, true);
						PlayerSpectatePlayer( i, playerid );
						SetPlayerInterior( i, GetPlayerInterior( playerid ) );
					}	
				}
			}
		}
	}	
	if(newstate == PLAYER_STATE_ONFOOT)
	{
	    HideSpeedo(playerid);
		StopAudioStreamForPlayerEx(playerid);
		if(GetPVarType(playerid, "Siren"))
		{
  			if(IsPlayerAttachedObjectSlotUsed(playerid, MAX_PLAYER_ATTACHED_OBJECTS - 2)) RemovePlayerAttachedObject(playerid, MAX_PLAYER_ATTACHED_OBJECTS - 2);
    		if(IsPlayerAttachedObjectSlotUsed(playerid, MAX_PLAYER_ATTACHED_OBJECTS - 1)) RemovePlayerAttachedObject(playerid, MAX_PLAYER_ATTACHED_OBJECTS - 1);
      		DeletePVar(playerid, "Siren");
		}

		/*if(GettingSpectated[playerid] != INVALID_PLAYER_ID && PlayerInfo[GettingSpectated[playerid]][pAdmin] >= 2) {
			new spectator = GettingSpectated[playerid];
	        // Preventing possible buffer overflows with the arrays
	 		TogglePlayerSpectating(spectator, true);
			PlayerSpectatePlayer( spectator, playerid );
			SetPlayerInterior( spectator, GetPlayerInterior( playerid ) );
			SetPlayerInterior( spectator, GetPlayerInterior( playerid ) );
			SetPlayerVirtualWorld( spectator, GetPlayerVirtualWorld( playerid ) );
		}*/

	    if(oldstate == PLAYER_STATE_DRIVER)
		{
			if (_vhudVisible[playerid] == 1)
			{
				HideSpeedo(playerid); // incase vehicle despawns
			}
			if (CarRadars[playerid] > 0)
			{
				PlayerTextDrawHide(playerid, _crTextTarget[playerid]);
				PlayerTextDrawHide(playerid, _crTextSpeed[playerid]);
				PlayerTextDrawHide(playerid, _crTickets[playerid]);
				DeletePVar(playerid, "_lastTicketWarning");
			}

			SetPlayerWeaponsEx(playerid);
		}
		else if(oldstate == PLAYER_STATE_PASSENGER) SetPlayerWeaponsEx(playerid);

		if(ConnectedToPC[playerid] == 1337)//mdc
	    {
            SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "* You are now logged off the MDC.");
	        ConnectedToPC[playerid] = 0;
		}
        if(TransportDuty[playerid] > 0)
		{
		    if(TransportDuty[playerid] == 1)
			{
		        TaxiDrivers -= 1;
			}
			else if(TransportDuty[playerid] == 2)
			{
			    BusDrivers -= 1;
			}
			TransportDuty[playerid] = 0;
			new string[70]; // increased buf size as full message wasn't getting shown
			format(string, sizeof(string), "* Ban da ngung lai xe va kiem duoc $%d.", TransportMoney[playerid]);
			SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);

			foreach(new i: Player)
			{
				if (TransportDriver[i] == playerid)
				{
					GivePlayerCash(i, -TransportCost[i]);
					format(string, sizeof(string), "* Nguoi lai xe da roi khoi chiec xe va ban phai tra $%d.", TransportCost[i]);
					TransportCost[i] = 0; // I've not used either of these two variables before, could be more that resetting
					TransportDriver[i] = INVALID_PLAYER_ID;
					SendClientMessageEx(i, COLOR_LIGHTBLUE, string);
				}
			}

			GivePlayerCash(playerid, TransportMoney[playerid]);
			TransportValue[playerid] = 0; TransportMoney[playerid] = 0;
			if(!IsATaxiDriver(playerid)) { SetPlayerColor(playerid, TEAM_HIT_COLOR); }
			TransportTime[playerid] = 0;
   			TransportCost[playerid] = 0;
		}
		if(TransportDriver[playerid] < MAX_PLAYERS)
		{
			new string[128];
			TransportMoney[TransportDriver[playerid]] += TransportCost[playerid];
			format(string, sizeof(string), "~w~Chi phi di xe~n~~r~$%d",TransportCost[playerid]);
			GameTextForPlayer(playerid, string, 5000, 3);
			format(string, sizeof(string), "~w~Khach hang da roi khoi xe ban~n~~g~kiem duoc $%d",TransportCost[playerid]);
			GameTextForPlayer(TransportDriver[playerid], string, 5000, 3);
			GivePlayerCash(playerid, -TransportCost[playerid]);

			if(TransportCost[playerid] >= 10000)
			{
				format(string, sizeof(string), "%s (IP:%s) has taxied %s (IP:%s) $%d in this session.", GetPlayerNameEx(playerid), GetPlayerIpEx(playerid), GetPlayerNameEx(TransportDriver[playerid]), GetPlayerIpEx(TransportDriver[playerid]), TransportCost[playerid]);
				//Log("logs/pay.log", string);
				ABroadCast(COLOR_YELLOW, string, 2);
			}
			TransportTime[TransportDriver[playerid]] = 0;
			TransportCost[TransportDriver[playerid]] = 0;
			TransportCost[playerid] = 0;
			TransportTime[playerid] = 0;
			TransportDriver[playerid] = INVALID_PLAYER_ID;
		}
	}
    if(newstate == PLAYER_STATE_PASSENGER) // TAXI & BUSSES
	{
	    #if defined zombiemode
   		if(zombieevent == 1 && GetPVarType(playerid, "pIsZombie"))
		{
			SendClientMessageEx(playerid, COLOR_GREY, "Zombies can't go into cars.");
			new Float:X, Float:Y, Float:Z;
			GetPlayerPos(playerid, X, Y, Z);
			SetPlayerPos(playerid, X, Y, Z);
			return 1;
		}
		#endif
		fVehSpeed[playerid] = 0;
		fVehHealth[playerid] = 0;
 		if(!isnull(stationidv[GetPlayerVehicleID(playerid)]))
		{
   			PlayAudioStreamForPlayerEx(playerid, stationidv[GetPlayerVehicleID(playerid)]);
		}
        new vehicleid = GetPlayerVehicleID(playerid);
	    /*if(vehicleid == NGVehicles[12] ||
		vehicleid == NGVehicles[13] ||
		vehicleid == NGVehicles[14] ||
		vehicleid == NGVehicles[15] ||
		vehicleid == NGVehicles[16] ||
		vehicleid == NGVehicles[17])
		{
		    TogglePlayerSpectating(playerid, 1);
			PlayerSpectateVehicle(playerid, vehicleid);
			SetPVarInt(playerid, "NGPassenger", 1);
			SetPVarInt(playerid, "NGPassengerVeh", vehicleid);
			SetPVarInt(playerid, "NGPassengerSkin", GetPlayerSkin(playerid));
			new Float:health, Float:armour;
			GetPlayerHealth(playerid, health);
			GetPlayerArmour(playerid, armour);
			SetPVarFloat(playerid, "NGPassengerHP", health);
			SetPVarFloat(playerid, "NGPassengerArmor", armour);
		}*/

        if(PlayerInfo[playerid][pGuns][4] > 0)	SetPlayerArmedWeapon(playerid,PlayerInfo[playerid][pGuns][4]);
		else SetPlayerArmedWeapon(playerid,0);

	    gLastCar[playerid] = vehicleid;
	    foreach(new i: Player)
	    {
     		if(IsPlayerInVehicle(i, vehicleid) && GetPlayerState(i) == 2 && TransportDuty[i] > 0)
       		{
				if(GetPlayerCash(playerid) < TransportValue[i])
				{
					new string[28];
					format(string, sizeof(string), "* You need $%d to enter.", TransportValue[i]);
					SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
					RemovePlayerFromVehicle(playerid);
					new Float:X, Float:Y, Float:Z;
					GetPlayerPos(playerid, X, Y, Z);
					SetPlayerPos(playerid, X, Y, Z+2);
					TogglePlayerControllable(playerid, 1);
				}
				else
				{
					new string[35+MAX_PLAYER_NAME];
					if(TransportDuty[i] == 1)
					{
						format(string, sizeof(string), "* You paid $%d to the taxi driver.", TransportValue[i]);
						SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
						format(string, sizeof(string), "* Passenger %s has entered your taxi.", GetPlayerNameEx(playerid));
						SendClientMessageEx(i, COLOR_LIGHTBLUE, string);
						TransportTime[i] = 1;
						TransportTime[playerid] = 1;
						TransportCost[playerid] = TransportValue[i];
						TransportCost[i] = TransportValue[i];
						TransportDriver[playerid] = i;
					}
					else if(TransportDuty[i] == 2)
					{
						format(string, sizeof(string), "* You paid $%d to the Taxi Driver.", TransportValue[i]);
						SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
						format(string, sizeof(string), "* Passenger %s has entered your Taxi.", GetPlayerNameEx(playerid));
						SendClientMessageEx(i, COLOR_LIGHTBLUE, string);
					}
					GivePlayerCash(playerid, - TransportValue[i]);
					TransportMoney[i] += TransportValue[i];
				}
      		}
	    }
	}
	if(newstate == PLAYER_STATE_WASTED)
	{
	    if(GetPVarInt(playerid, "EventToken") == 0)
	    {
			SetPVarInt(playerid, "MedicBill", 1);
		}
		if(ConnectedToPC[playerid] == 1337)//mdc
	    {
	        ConnectedToPC[playerid] = 0;
		}
		Seatbelt[playerid] = 0;
	}
	if(newstate == PLAYER_STATE_DRIVER)
	{
	    #if defined zombiemode
    	if(zombieevent == 1 && GetPVarType(playerid, "pIsZombie"))
		{
			SendClientMessageEx(playerid, COLOR_GREY, "Zombies can't drive.");
			new Float:X, Float:Y, Float:Z;
			GetPlayerPos(playerid, X, Y, Z);
			SetPlayerPos(playerid, X, Y, Z);
			return 1;
		}
		#endif
		fVehSpeed[playerid] = 0;
		fVehHealth[playerid] = 0;
	    if(!isnull(stationidv[GetPlayerVehicleID(playerid)]))
		{
   			PlayAudioStreamForPlayerEx(playerid, stationidv[GetPlayerVehicleID(playerid)]);
		}

		SetPlayerArmedWeapon(playerid, 0);

		new
			newcar = GetPlayerVehicleID(playerid),
			engine, lights, alarm, doors, bonnet, boot, objective, v;

		gLastCar[playerid] = newcar;
		if(GetPVarInt(playerid, "EventToken") == 1) {
			if(EventKernel[EventFootRace] == 1) {
				new Float:X, Float:Y, Float:Z;
				GetPlayerPos(playerid, X, Y, Z);
				SetPlayerPos(playerid, X, Y, Z+1.3);
				SendClientMessageEx(playerid, COLOR_WHITE, "You cannot be inside vehicles and participate in this event at the same time.");
				return 1;
			}
		}
	 	foreach(new i: Player)
		{
	   		v = GetPlayerVehicle(i, newcar);
		    if(v != -1) {
				if(i == playerid) {

					new
						string[128];

					format(string, sizeof(string),"You are the owner of this %s.", GetVehicleName(newcar));
					SendClientMessageEx(playerid, COLOR_GREY, string);
					if(PlayerVehicleInfo[i][v][pvTicket] != 0)
					{
						format(string, sizeof(string),"This vehicle has $%d unpaid tickets. You must pay the ticket at the DMV in Dilimore.", PlayerVehicleInfo[i][v][pvTicket]);
						SendClientMessageEx(playerid, COLOR_GREY, string);
						SendClientMessageEx(playerid, COLOR_GREY, "Failure to pay these tickets as soon as possible will result in further fines, vehicle impounding, or even an arrest.");
					}
				}
				else if(i == PlayerInfo[playerid][pVehicleKeysFrom] && v == PlayerInfo[playerid][pVehicleKeys]) {

					new
						string[64 + MAX_PLAYER_NAME];

					format(string, sizeof(string),"You have the keys for this %s from owner %s.", GetVehicleName(newcar), GetPlayerNameEx(i));
					SendClientMessageEx(playerid, COLOR_GREY, string);
				}
				else if(PlayerVehicleInfo[i][v][pvLocked] == 1 && PlayerVehicleInfo[i][v][pvLock] == 1) {
				    GetVehicleParamsEx(newcar,engine,lights,alarm,doors,bonnet,boot,objective);
					SetVehicleParamsEx(newcar,engine,lights,VEHICLE_PARAMS_ON,doors,bonnet,boot,objective);
					SetTimerEx("DisableVehicleAlarm", 20000, 0, "d",  newcar);
				}
				else if(PlayerVehicleInfo[i][v][pvLocked] == 1 && PlayerVehicleInfo[i][v][pvLock] == 2) { // Electronic Lock System

					new
						string[49 + MAX_PLAYER_NAME];

	          		if(PlayerInfo[playerid][pAdmin] < 2)
					{
						new Float:slx, Float:sly, Float:slz;
						GetPlayerPos(playerid, slx, sly, slz);
						SetPlayerPos(playerid, slx, sly, slz+1.3);
						RemovePlayerFromVehicle(playerid);
						defer NOPCheck(playerid);
					}
					else
					{
	    				format(string, sizeof(string), "Warning: This %s is owned by %s.", GetVehicleName(newcar), GetPlayerNameEx(i));
	      				SendClientMessageEx(playerid, COLOR_GREY, string);
					}
				}
				return 1;
			}
		}
		new vehicleid = newcar;
		if(IsVIPcar(vehicleid))
		{
		    if(PlayerInfo[playerid][pDonateRank] > 0)
			{
				SendClientMessageEx(playerid, COLOR_YELLOW, "VIP: This is a VIP vehicle from the VIP garage, therefore it has unlimited fuel.");
			}
		    else
			{
			    new Float:slx, Float:sly, Float:slz;
				GetPlayerPos(playerid, slx, sly, slz);
				SetPlayerPos(playerid, slx, sly, slz+1.3);
				PlayerPlaySound(playerid, 1130, slx, sly, slz+1.3);
			    RemovePlayerFromVehicle(playerid);
			    defer NOPCheck(playerid);
			    SendClientMessageEx(playerid, COLOR_GRAD2, "You are not a VIP, this is a vehicle from the VIP Garage!");
			}
		}
		else if(IsFamedVeh(vehicleid))
		{
		    if(PlayerInfo[playerid][pFamed] < 1)
		    {
		        new Float:slx, Float:sly, Float:slz;
				GetPlayerPos(playerid, slx, sly, slz);
				SetPlayerPos(playerid, slx, sly, slz+1.3);
				PlayerPlaySound(playerid, 1130, slx, sly, slz+1.3);
			    RemovePlayerFromVehicle(playerid);
			    defer NOPCheck(playerid);
			    SendClientMessageEx(playerid, COLOR_GRAD2, "You are not a Famed Member, this is a vehicle from the Famed Garage!");
			 }
			 else {
			    SendClientMessageEx(playerid, COLOR_YELLOW, "Famed: This is a Famed vehicle from the Famed garage, therefore it has unlimited fuel.");
			 }
		}
		else if(DynVeh[vehicleid] != -1)
		{
			new string[128], Float:slx, Float:sly, Float:slz;
			GetPlayerPos(playerid, slx, sly, slz);
			if(DynVehicleInfo[DynVeh[vehicleid]][gv_igID] != INVALID_GROUP_ID && (PlayerInfo[playerid][pMember] != DynVehicleInfo[DynVeh[vehicleid]][gv_igID]))
			{
				RemovePlayerFromVehicle(playerid);
				SetPlayerPos(playerid, slx, sly, slz+1.3);
				defer NOPCheck(playerid);
				format(string, sizeof(string), "You need to be in %s to drive this vehicle.", arrGroupData[DynVehicleInfo[DynVeh[vehicleid]][gv_igID]][g_szGroupName]);
				SendClientMessageEx(playerid, COLOR_GRAD2, string);
			}
			else if(DynVehicleInfo[DynVeh[vehicleid]][gv_igDivID] != 0 && PlayerInfo[playerid][pDivision] != DynVehicleInfo[DynVeh[vehicleid]][gv_igDivID])
			{
				RemovePlayerFromVehicle(playerid);
				SetPlayerPos(playerid, slx, sly, slz+1.3);
				defer NOPCheck(playerid);
				format(string, sizeof(string), "You need to be in %s's %s division to drive this vehicle.",
				arrGroupData[DynVehicleInfo[DynVeh[vehicleid]][gv_igID]][g_szGroupName],
				arrGroupDivisions[DynVehicleInfo[DynVeh[vehicleid]][gv_igID]][DynVehicleInfo[DynVeh[vehicleid]][gv_igDivID]]);
				SendClientMessageEx(playerid, COLOR_GRAD2, string);
			}
			else if(DynVehicleInfo[DynVeh[vehicleid]][gv_ifID] != 0 && (PlayerInfo[playerid][pFMember] != DynVehicleInfo[DynVeh[vehicleid]][gv_ifID]))
			{
				RemovePlayerFromVehicle(playerid);
				SetPlayerPos(playerid, slx, sly, slz+1.3);
				defer NOPCheck(playerid);
			}
			else if(DynVehicleInfo[DynVeh[vehicleid]][gv_irID] != 0 && (PlayerInfo[playerid][pRank] < DynVehicleInfo[DynVeh[vehicleid]][gv_irID]))
			{
				RemovePlayerFromVehicle(playerid);
				SetPlayerPos(playerid, slx, sly, slz+1.3);
				defer NOPCheck(playerid);
			}
		}
	   	else if(IsAPlane(vehicleid))
		{
	  		if(PlayerInfo[playerid][pFlyLic] != 1)
	  		{
		  		RemovePlayerFromVehicle(playerid);
		  		new Float:slx, Float:sly, Float:slz;
				GetPlayerPos(playerid, slx, sly, slz);
				SetPlayerPos(playerid, slx, sly, slz);
		  		defer NOPCheck(playerid);
			 	SendClientMessageEx(playerid,COLOR_GREY,"You don't have a pilot license!");
	  		}
		}
		else if(IsAHelicopter(vehicleid))
		{
		    PlayerInfo[playerid][pAGuns][GetWeaponSlot(46)] = 46;
			GivePlayerValidWeapon(playerid, 46, 60000);
		}
		else if(IsAnTaxi(vehicleid) || IsAnBus(vehicleid))
		{
	        if(PlayerInfo[playerid][pJob] == 17 || PlayerInfo[playerid][pJob2] == 17 || IsATaxiDriver(playerid) || PlayerInfo[playerid][pTaxiLicense] == 1)
			{
			}
		    else
			{
		        SendClientMessageEx(playerid,COLOR_GREY,"   You are not a Taxi/Bus Driver!");
		        RemovePlayerFromVehicle(playerid);
		        new Float:slx, Float:sly, Float:slz;
				GetPlayerPos(playerid, slx, sly, slz);
				SetPlayerPos(playerid, slx, sly, slz);
				defer NOPCheck(playerid);
		    }
		}

		if(GetCarBusiness(newcar) != INVALID_BUSINESS_ID && PlayerInfo[playerid][pAdmin] < 1337)
        {

            new
				iBusiness = GetCarBusiness(newcar),
				iSlot = GetBusinessCarSlot(newcar),
				string[128];

			if(Businesses[iBusiness][bInventory] == 0) {
			    SendClientMessageEx(playerid,COLOR_GREY,"This dealership is out of stock.");
		        RemovePlayerFromVehicle(playerid);
		        new Float:slx, Float:sly, Float:slz;
				GetPlayerPos(playerid, slx, sly, slz);
				SetPlayerPos(playerid, slx, sly, slz);
				defer NOPCheck(playerid);
				return 1;
			}
			format(string, sizeof(string), "Would you like to purchase this %s\nThis vehicle costs $%s.", GetVehicleName(newcar), number_format(Businesses[iBusiness][bPrice][iSlot]));
		    ShowPlayerDialog(playerid,DIALOG_CDBUY,DIALOG_STYLE_MSGBOX,"Buy Vehicle",string,"Buy","Cancel");
		    TogglePlayerControllable(playerid, false);
		    return 1;
        }
	    if(DynVeh[vehicleid] != -1 && DynVehicleInfo[DynVeh[vehicleid]][gv_iType] == 1)
	    {
	        SendClientMessageEx(playerid, COLOR_GRAD1, "Crate Related Commands: /loadforklift /(un)loadplane /cargo /igps /announcetakeoff /cgun /crates /destroycrate /cratelimit");
	        SendClientMessageEx(playerid, COLOR_GRAD1, " /(un)loadcrate /delivercrate");
	    }
		GetVehicleParamsEx(newcar,engine,lights,alarm,doors,bonnet,boot,objective);
		if((engine == VEHICLE_PARAMS_UNSET || engine == VEHICLE_PARAMS_OFF) && GetVehicleModel(newcar) != 509 && GetVehicleModel(newcar) != 481 && GetVehicleModel(newcar) != 510 && (DynVeh[newcar] != -1 && GetVehicleModel(newcar) == 592 && DynVehicleInfo[DynVeh[newcar]][gv_iType] != 1) ) {
			SendClientMessageEx(playerid, COLOR_GREEN, "Dong co cua phuong tien nay khong chay - Neu ban muon khoi dong lai, Nhan {FFFFFF}N{33AA33} de Khoi Dong .");
		}
		else if((engine == VEHICLE_PARAMS_UNSET || engine == VEHICLE_PARAMS_OFF) && (DynVeh[newcar] != -1 && GetVehicleModel(newcar) == 592 && DynVehicleInfo[DynVeh[newcar]][gv_iType] == 1))
		{
			SendClientMessageEx(playerid, COLOR_WHITE, "You must request clearance to take off. /announcetakeoff to put in the request.");
		}
	}
	if((newstate == 2 || newstate == 3 || newstate == 7 || newstate == 9) && pTazer{playerid} == 1)
	{
		GivePlayerValidWeapon(playerid, pTazerReplace{playerid}, 60000);
		pTazer{playerid} = 0;
	}
	if(newstate == PLAYER_STATE_SPAWNED)
	{
		if(ConnectedToPC[playerid] == 1337)//mdc
	    {
	        ConnectedToPC[playerid] = 0;
		}
	}
	return 1;
}
Reply
#4

I think the problem is from SetPlayerWeaponEx function, as you said the player lost their weapons when they leave a vehicle.
Maybe, show us SetPlayerWeaponEx() function?
and use pastebin next time if you want to post long code.
Код:
if(oldstate == PLAYER_STATE_DRIVER)
{
	if (_vhudVisible[playerid] == 1)
	{
		HideSpeedo(playerid); // incase vehicle despawns
	}
	if (CarRadars[playerid] > 0)
	{
		PlayerTextDrawHide(playerid, _crTextTarget[playerid]);
		PlayerTextDrawHide(playerid, _crTextSpeed[playerid]);
		PlayerTextDrawHide(playerid, _crTickets[playerid]);
		DeletePVar(playerid, "_lastTicketWarning");
	}

	SetPlayerWeaponsEx(playerid);
}
else if(oldstate == PLAYER_STATE_PASSENGER) SetPlayerWeaponsEx(playerid);
Reply
#5

what do i now ?
- coppy code in funtions ?
how ?
Reply
#6

No, that's just a part of your code, can you show us your SetPlayerWeaponsEx() function?
Reply
#7

Код HTML:
stock SetPlayerWeapons(playerid)
{
    if(HungerPlayerInfo[playerid][hgInEvent] == 1) { return 1;}
    if(GetPVarInt(playerid, "IsInArena") >= 0) { return 1; }
	ResetPlayerWeapons(playerid);
	for(new s = 0; s < 12; s++)
	{
		if(PlayerInfo[playerid][pGuns][s] > 0 && PlayerInfo[playerid][pAGuns][s] == 0)
		{
		    switch ( s )
		    {
			    case 0, 1, 10, 11, 12:
			    {
			        GivePlayerValidWeapon(playerid, PlayerInfo[playerid][pGuns][s], 20);
			    }
			    case 2:
			    {
			        GivePlayerValidWeapon(playerid, PlayerInfo[playerid][pGuns][s], PlayerInfo[playerid][pAmmo][1]);// 9mm, sdpid, DE
			    }
			    case 3:
			    {
			        GivePlayerValidWeapon(playerid, PlayerInfo[playerid][pGuns][s], PlayerInfo[playerid][pAmmo][2]);// Shotgun, spawn-off, combat shotgun
			    }
			    case 4:
			    {
			        GivePlayerValidWeapon(playerid, PlayerInfo[playerid][pGuns][s], PlayerInfo[playerid][pAmmo][3]);// Uzi, Tec9, Mp5
			    }
			    case 5:
			    {
			        GivePlayerValidWeapon(playerid, PlayerInfo[playerid][pGuns][s], PlayerInfo[playerid][pAmmo][4]);// M4, Ak 47
			    }
			    case 6:
			    {
			        GivePlayerValidWeapon(playerid, PlayerInfo[playerid][pGuns][s], PlayerInfo[playerid][pAmmo][5]);// rifle, sniper
			    }
			    case 7:
			    {
			        GivePlayerValidWeapon(playerid, PlayerInfo[playerid][pGuns][s], PlayerInfo[playerid][pAmmo][6]);// Bazoka, RPG, Firegun, minigun
			    }
			    case 8:
			    {
			        GivePlayerValidWeapon(playerid, PlayerInfo[playerid][pGuns][s], PlayerInfo[playerid][pAmmo][7]);// SATCHEL, GRENADE, TEARGAS, MOLTOV
			    }
			    case 9:
			    {
			        GivePlayerValidWeapon(playerid, PlayerInfo[playerid][pGuns][s], PlayerInfo[playerid][pAmmo][8]);// SPRAYCAN, FIREEXTINGUISHER, CAMERA
			    }
			}
		}
	}
	return 1;
}

stock SetPlayerWeaponsEx(playerid)
{
	ResetPlayerWeapons(playerid);
	for(new s = 0; s < 12; s++)
	{
		if(PlayerInfo[playerid][pGuns][s] > 0)
		{
			GivePlayerValidWeapon(playerid, PlayerInfo[playerid][pGuns][s], PlayerInfo[playerid][pAmmo][s]);
		}
	}
	SetPlayerArmedWeapon(playerid, GetPVarInt(playerid, "LastWeapon"));
}
Reply
#8

Time to show GivePlayerValidWeapon
Reply
#9

Код HTML:
stock SetPlayerWeapons(playerid)
{
    if(HungerPlayerInfo[playerid][hgInEvent] == 1) { return 1;}
    if(GetPVarInt(playerid, "IsInArena") >= 0) { return 1; }
	ResetPlayerWeapons(playerid);
	for(new s = 0; s < 12; s++)
	{
		if(PlayerInfo[playerid][pGuns][s] > 0 && PlayerInfo[playerid][pAGuns][s] == 0)
		{
		    switch ( s )
		    {
			    case 0, 1, 10, 11, 12:
			    {
			        GivePlayerValidWeapon(playerid, PlayerInfo[playerid][pGuns][s], 20);
			    }
			    case 2:
			    {
			        GivePlayerValidWeapon(playerid, PlayerInfo[playerid][pGuns][s], PlayerInfo[playerid][pAmmo][1]);// 9mm, sdpid, DE
			    }
			    case 3:
			    {
			        GivePlayerValidWeapon(playerid, PlayerInfo[playerid][pGuns][s], PlayerInfo[playerid][pAmmo][2]);// Shotgun, spawn-off, combat shotgun
			    }
			    case 4:
			    {
			        GivePlayerValidWeapon(playerid, PlayerInfo[playerid][pGuns][s], PlayerInfo[playerid][pAmmo][3]);// Uzi, Tec9, Mp5
			    }
			    case 5:
			    {
			        GivePlayerValidWeapon(playerid, PlayerInfo[playerid][pGuns][s], PlayerInfo[playerid][pAmmo][4]);// M4, Ak 47
			    }
			    case 6:
			    {
			        GivePlayerValidWeapon(playerid, PlayerInfo[playerid][pGuns][s], PlayerInfo[playerid][pAmmo][5]);// rifle, sniper
			    }
			    case 7:
			    {
			        GivePlayerValidWeapon(playerid, PlayerInfo[playerid][pGuns][s], PlayerInfo[playerid][pAmmo][6]);// Bazoka, RPG, Firegun, minigun
			    }
			    case 8:
			    {
			        GivePlayerValidWeapon(playerid, PlayerInfo[playerid][pGuns][s], PlayerInfo[playerid][pAmmo][7]);// SATCHEL, GRENADE, TEARGAS, MOLTOV
			    }
			    case 9:
			    {
			        GivePlayerValidWeapon(playerid, PlayerInfo[playerid][pGuns][s], PlayerInfo[playerid][pAmmo][8]);// SPRAYCAN, FIREEXTINGUISHER, CAMERA
			    }
			}
		}
	}
	return 1;
}

stock SetPlayerWeaponsEx(playerid)
{
	ResetPlayerWeapons(playerid);
	for(new s = 0; s < 12; s++)
	{
		if(PlayerInfo[playerid][pGuns][s] > 0)
		{
			GivePlayerValidWeapon(playerid, PlayerInfo[playerid][pGuns][s], PlayerInfo[playerid][pAmmo][s]);
		}
	}
	SetPlayerArmedWeapon(playerid, GetPVarInt(playerid, "LastWeapon"));
}
Reply
#10

Код HTML:
stock GivePlayerValidWeapon( playerid, WeaponID , Ammo)
{
	switch( WeaponID )
	{
  		case 0, 1:
		{
			PlayerInfo[playerid][pGuns][ 0 ] = WeaponID;
			GivePlayerWeapon( playerid, WeaponID, 2 );
		}
		case 2, 3, 4, 5, 6, 7, 8, 9:
		{
			PlayerInfo[playerid][pGuns][ 1 ] = WeaponID;
			GivePlayerWeapon( playerid, WeaponID, 2 );
		}
		case 10, 11, 12, 13, 14, 15:
		{
			PlayerInfo[playerid][pGuns][ 10 ] = WeaponID;
			GivePlayerWeapon( playerid, WeaponID, 2 );
		}
		case 16, 17, 18, 39:
		{
			PlayerInfo[playerid][pGuns][ 8 ] = WeaponID;
			GivePlayerWeapon(playerid, WeaponID, Ammo);
			PlayerInfo[playerid][pAmmo][7] = Ammo;
		}
		case 22, 23, 24: // 9mm, sdpid, DE
		{
			PlayerInfo[playerid][pGuns][ 2 ] = WeaponID;
			PlayerInfo[playerid][pAmmo][1] = Ammo;
			GivePlayerWeapon(playerid, WeaponID, Ammo);
		}
		case 25,26,27: // Shotgun, spawn-off, combat shotgun
		{
			PlayerInfo[playerid][pGuns][ 3 ] = WeaponID;
			PlayerInfo[playerid][pAmmo][2] = Ammo;
			GivePlayerWeapon(playerid, WeaponID, Ammo);
		}
		case 28,29,32: // Uzi, Tec9, Mp5
		{
			PlayerInfo[playerid][pGuns][ 4 ] = WeaponID;
			PlayerInfo[playerid][pAmmo][3] = Ammo;
			GivePlayerWeapon(playerid, WeaponID, Ammo);
		}
		case 30,31: // M4, Ak 47
		{
			PlayerInfo[playerid][pGuns][ 5 ] = WeaponID;
			PlayerInfo[playerid][pAmmo][4] = Ammo;
			GivePlayerWeapon(playerid, WeaponID, Ammo);
		}
		case 33,34: // rifle, sniper
		{
			PlayerInfo[playerid][pGuns][ 6 ] = WeaponID;
			PlayerInfo[playerid][pAmmo][5] = Ammo;
			GivePlayerWeapon(playerid, WeaponID, Ammo);
		}
		case 35,36,37,38: // Bazoka, RPG, Firegun, minigun
		{
			PlayerInfo[playerid][pGuns][ 7 ] = WeaponID;
			PlayerInfo[playerid][pAmmo][6] = Ammo;
			GivePlayerWeapon(playerid, WeaponID, Ammo);
		}
		case 40,41,42,43: // SPRAYCAN, FIREEXTINGUISHER, CAMERA
		{
			PlayerInfo[playerid][pGuns][ 9 ] = WeaponID;
			PlayerInfo[playerid][pAmmo][8] = Ammo;
			GivePlayerWeapon(playerid, WeaponID, Ammo);
		}
		case 44, 45, 46:
		{
			PlayerInfo[playerid][pGuns][ 11 ] = WeaponID;
			GivePlayerWeapon( playerid, WeaponID, LUONGDAN_BANDAU );
		}
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)