Basically whenever a player gets into a faction vehicle and gets out, their weapons disappear. I have looked up and down the script and could not pinpoint the situation, only a suspected location here:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
new string[128];
if(newstate == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(Vehicles[vehicleid][CarJob])
{
SendClientMessage(playerid, GREY, "NOTICE: You have entered a side-job car. Using this for personal usage will result in an A-jail.");
}
SavePlayerData(playerid);
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
if(engine == 0) {
SendClientMessage(playerid, WHITE, "To start your vehicle's engine, use {00FF00}SPACE");
}
if(floatround(Vehicles[GetPlayerVehicleID(playerid)][Fuel]) <= 0)
{
format(string,sizeof(string),"~g~ Fuel: ~w~ 0");
SendClientMessage(playerid, COLOR_RED, "This vehicle has ran out of fuel");
KillTimer(FuelTimer[playerid]);
ToggleVehicleEngine(GetPlayerVehicleID(playerid), false);
TextDrawSetString(FuelText[playerid], string);
TextDrawShowForPlayer(playerid, SpeedText[playerid]);
SpeedTimer[playerid] = SetTimerEx("SpeedUpdate", 1000, true, "i", playerid);
TextDrawSetString(SpeedText[playerid], string);
TextDrawShowForPlayer(playerid, SpeedText[playerid]);
}
else
{
FuelTimer[playerid] = SetTimerEx("FuelDown", 1000, true, "i", playerid); // Fueldown timer
TextDrawShowForPlayer(playerid, FuelText[playerid]);
TextDrawShowForPlayer(playerid, SpeedText[playerid]);
SpeedTimer[playerid] = SetTimerEx("SpeedUpdate", 1000, true, "i", playerid);
TextDrawSetString(SpeedText[playerid], string);
TextDrawShowForPlayer(playerid, SpeedText[playerid]);
}
}
else
{
TextDrawHideForPlayer(playerid,FuelText[playerid]);
TextDrawSetString(FuelText[playerid], " ");
}
if ((oldstate == PLAYER_STATE_DRIVER) && (newstate == PLAYER_STATE_ONFOOT))
{
TextDrawHideForPlayer(playerid, FuelText[playerid]);
TextDrawHideForPlayer(playerid, SpeedText[playerid]);
}
if ((oldstate == PLAYER_STATE_DRIVER) && (newstate == PLAYER_STATE_DRIVER))
{
new vehicleid = GetPlayerVehicleID(playerid);
new Float:health;
GetVehicleHealth(vehicleid, health);
if(vehEngine[vehicleid] == 1)
{
if(health > 300)
{
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, objective);
vehEngine[vehicleid] = 0;
format(string, sizeof(string), "* A loud BANG sound is heard from %s's vehicle as it rolls to a dead stop.", pRPName(playerid));
NearByMessage(playerid, 0xFFA8FFFF, string);
SendClientMessage(playerid, RED, "Your vehicle has taken too much damage and will not go any further!");
}
}
}
if ((oldstate == PLAYER_STATE_ONFOOT) && (newstate == PLAYER_STATE_DRIVER))
{
if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 510 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 511)
{
new vehicleid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
vehEngine[vehicleid] = 1;
}
}
if ((oldstate == PLAYER_STATE_ONFOOT) && (newstate == PLAYER_STATE_DRIVER))
{
if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 438)
{
if(Jobs[Player[playerid][Job]][JobType] == 9)
{
SendClientMessage(playerid, GREY, "You may now go on Taxi Duty via /taxiduty!");
}
else
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, GREY, "You do not have the keys to this vehicle! (You must be a taxi driver)");
}
}
}
if ((oldstate == PLAYER_STATE_ONFOOT) && (newstate == PLAYER_STATE_PASSENGER || newstate == PLAYER_STATE_DRIVER))
{
OldVehID [playerid] = GetPlayerVehicleID (playerid);
}
new vehicleid = GetPlayerVehicleID(playerid);
new Float:health;
GetVehicleHealth(vehicleid, health);
if(newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT)
{
new string2[128];
new PlayerVehicle = GetVehicleFileID(GetPlayerVehicleID(playerid));
if(Vehicles[PlayerVehicle][CarGroup] != 0 && Vehicles[PlayerVehicle][CarGroup] != Player[playerid][Group])
{
format(string2, sizeof(string2), "This vehicle is only usable by %s.", Groups[Vehicles[PlayerVehicle][CarGroup]][GroupName]);
SendClientMessage(playerid, WHITE, string2);
RemovePlayerFromVehicle(playerid);
}
else if(IsAnOwnedCar(vehicleid))
{
if(Player[playerid][AdminLevel] < 1)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(Player[i][LockedCar] == 1 && Player[i][CarLinkID] == vehicleid)
{
SendClientMessage(playerid, WHITE, "This vehicle is locked.");
RemovePlayerFromVehicle(i);
}
if(Player[i][LockedCar2] == 1 && Player[i][Car2LinkID] == vehicleid)
{
SendClientMessage(playerid, WHITE, "This vehicle is locked.");
RemovePlayerFromVehicle(i);
}
if(Player[i][LockedCar3] == 1 && Player[i][Car3LinkID] == vehicleid)
{
SendClientMessage(playerid, WHITE, "This vehicle is locked.");
RemovePlayerFromVehicle(i);
}
}
}
}
}
return 1;
}
I have a feeling the error is in your 'SavePlayerData', can you show us the code for that function?
pawn Код:
public SavePlayerData(playerid)
{
if(Player[playerid][Authenticated] == 1)
{
GetPlayerPos(playerid, Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ]);
GetPlayerHealth(playerid, Player[playerid][LastHealth]);
GetPlayerArmour(playerid, Player[playerid][LastArmour]);
Player[playerid][LastInterior] = GetPlayerInterior(playerid);
GetPlayerWeaponData(playerid, Player[playerid][SMGWeapon], Player[playerid][SMGWeapon], Player[playerid][SMGWeaponAmmo]);
new string[128];
if(Player[playerid][AdminDuty] >= 1)
{
format(string, sizeof(string), "Accounts/%s.ini", Player[playerid][NormalName]);
}
else
{
format(string, sizeof(string), "Accounts/%s.ini", GetName(playerid));
}
if(!fexist(string))
{
dini_Create(string);
}
GetPlayerAmmo(playerid);
dini_Set(string, "Password", Player[playerid][Password]);
dini_IntSet(string, "SpawnSelection", Player[playerid][SpawnSelection]);
dini_IntSet(string, "AdminLevel", Player[playerid][AdminLevel]);
dini_FloatSet(string, "LastX", Player[playerid][LastX]);
dini_FloatSet(string, "LastY", Player[playerid][LastY]);
dini_FloatSet(string, "LastZ", Player[playerid][LastZ]);
dini_IntSet(string, "LastWorld", Player[playerid][LastWorld]);
dini_IntSet(string, "LastInterior", Player[playerid][LastInterior]);
if(Player[playerid][AdminDuty] == 0)
{
dini_IntSet(string, "LastSkin", GetPlayerSkin(playerid));
}
dini_FloatSet(string, "LastHealth", Player[playerid][LastHealth]);
dini_FloatSet(string, "LastArmour", Player[playerid][LastArmour]);
dini_IntSet(string, "LastLoginMinute", Player[playerid][LastLoginMinute]);
dini_IntSet(string, "LastLoginHour", Player[playerid][LastLoginHour]);
dini_IntSet(string, "LastLoginDay", Player[playerid][LastLoginDay]);
dini_IntSet(string, "LastLoginMonth", Player[playerid][LastLoginMonth]);
dini_IntSet(string, "LastLoginYear", Player[playerid][LastLoginYear]);
dini_Set(string, "LastIP", Player[playerid][LastIP]);
dini_IntSet(string, "Group", Player[playerid][Group]);
dini_IntSet(string, "GroupRank", Player[playerid][GroupRank]);
dini_IntSet(string, "House", Player[playerid][House]);
dini_IntSet(string, "Banned", Player[playerid][Banned]);
dini_IntSet(string, "Muted", Player[playerid][Muted]);
dini_IntSet(string, "Money", Player[playerid][Money]);
dini_IntSet(string, "FishBait", Player[playerid][FishBait]);
dini_IntSet(string, "FishtoEat", Player[playerid][FishtoEat]);
dini_IntSet(string, "FishingLine", Player[playerid][FishingLine]);
dini_IntSet(string, "FarmEmployed", Player[playerid][FarmEmployed]);
dini_IntSet(string, "FarmOwner", Player[playerid][FarmEmployed]);
dini_IntSet(string, "SMGWeapon", Player[playerid][SMGWeapon]);
dini_IntSet(string, "Toolkit", Player[playerid][Toolkit]);
dini_IntSet(string, "SevQuiz", Player[playerid][SevQuiz]);
dini_IntSet(string, "SMGWeaponAmmo", Player[playerid][SMGWeaponAmmo]);
dini_IntSet(string, "PistolWeapon", Player[playerid][PistolWeapon]);
dini_IntSet(string, "PistolWeaponAmmo", Player[playerid][PistolWeaponAmmo]);
dini_IntSet(string, "RifleWeapon", Player[playerid][RifleWeapon]);
dini_IntSet(string, "RifleWeaponAmmo", Player[playerid][RifleWeaponAmmo]);
dini_IntSet(string, "AssaultWeapon", Player[playerid][AssaultWeapon]);
dini_IntSet(string, "AssaultWeaponAmmo", Player[playerid][AssaultWeaponAmmo]);
dini_IntSet(string, "ShotgunWeapon", Player[playerid][ShotgunWeapon]);
dini_IntSet(string, "ShotgunAmmo", Player[playerid][ShotgunWeaponAmmo]);
dini_IntSet(string, "SprayWeapon", Player[playerid][SprayWeapon]);
dini_IntSet(string, "SprayWeaponAmmo", Player[playerid][SprayWeaponAmmo]);
dini_IntSet(string, "CombatWeapon", Player[playerid][CombatWeapon]);
dini_IntSet(string, "CombatWeaponAmmo", Player[playerid][CombatWeaponAmmo]);
dini_IntSet(string, "ThrownWeapon", Player[playerid][ThrownWeapon]);
dini_IntSet(string, "ThrownWeaponAmmo", Player[playerid][ThrownWeaponAmmo]);
dini_Set(string, "Warning1", Player[playerid][Warning1]);
dini_Set(string, "Warning2", Player[playerid][Warning2]);
dini_Set(string, "Warning3", Player[playerid][Warning3]);
dini_IntSet(string, "Identity", Player[playerid][Identity]);
dini_IntSet(string, "Age", Player[playerid][Age]);
dini_IntSet(string, "ContractPrice", Player[playerid][ContractPrice]);
dini_Set(string, "Contract", Player[playerid][Contract]);
dini_IntSet(string, "PrisonDuration", Player[playerid][PrisonDuration]);
dini_IntSet(string, "PrisonID", Player[playerid][PrisonID]);
dini_IntSet(string, "Tutorial", Player[playerid][Tutorial]);
dini_IntSet(string, "Hospitalized", Player[playerid][Hospitalized]);
dini_IntSet(string, "CriminalOffences", Player[playerid][CriminalOffences]);
dini_Set(string, "Offence1", Player[playerid][Offence1]);
dini_Set(string, "Offence2", Player[playerid][Offence2]);
dini_Set(string, "Offence3", Player[playerid][Offence3]);
dini_Set(string, "Offence4", Player[playerid][Offence4]);
dini_Set(string, "Offence5", Player[playerid][Offence5]);
dini_Set(string, "Offence6", Player[playerid][Offence6]);
dini_IntSet(string, "Gender", Player[playerid][Gender]);
dini_IntSet(string, "Job", Player[playerid][Job]);
dini_IntSet(string, "Materials", Player[playerid][Materials]);
dini_IntSet(string, "AdminActions", Player[playerid][AdminActions]);
dini_IntSet(string, "SecondsLoggedIn", Player[playerid][SecondsLoggedIn]);
dini_IntSet(string, "BankMoney", Player[playerid][BankMoney]);
dini_IntSet(string, "Crack", Player[playerid][Cocaine]);
dini_IntSet(string, "Pot", Player[playerid][Pot]);
dini_IntSet(string, "nMuted", Player[playerid][nMuted]);
dini_IntSet(string, "Business", Player[playerid][Business]);
dini_IntSet(string, "PhoneN", Player[playerid][PhoneN]);
dini_IntSet(string, "PlayingHours", Player[playerid][PlayingHours]);
dini_IntSet(string, "PhoneBook", Player[playerid][PhoneBook]);
dini_IntSet(string, "InabilityToMatrun", Player[playerid][InabilityToMatrun]);
dini_IntSet(string, "InabilityToDropCar", Player[playerid][InabilityToDropCar]);
dini_IntSet(string, "CantFish", Player[playerid][CantFish]);
dini_IntSet(string, "CollectedFish", Player[playerid][CollectedFish]);
dini_FloatSet(string, "CarX", Player[playerid][CarX]);
dini_FloatSet(string, "CarY", Player[playerid][CarY]);
dini_FloatSet(string, "CarZ", Player[playerid][CarZ]);
dini_FloatSet(string, "CarZAngle", Player[playerid][CarZAngle]);
dini_IntSet(string, "CarModel", Player[playerid][PlayerCarModel]);
dini_IntSet(string, "CarCol1", Player[playerid][CarCol1]);
dini_IntSet(string, "CarCol2", Player[playerid][CarCol2]);
dini_IntSet(string, "Rope", Player[playerid][Rope]);
dini_IntSet(string, "Rags", Player[playerid][Rags]);
dini_IntSet(string, "FailedHits", Player[playerid][FailedHits]);
dini_IntSet(string, "SuccessfulHits", Player[playerid][SuccessfulHits]);
dini_IntSet(string, "CarLock", Player[playerid][LockedCar]);
dini_IntSet(string, "Radio", Player[playerid][HasRadio]);
dini_IntSet(string, "CollegeMedia", Player[playerid][CollegeMedia]);
dini_IntSet(string, "CollegeLaw", Player[playerid][CollegeLaw]);
dini_IntSet(string, "CollegeEng", Player[playerid][CollegeEng]);
dini_IntSet(string, "CollegeMath", Player[playerid][CollegeMath]);
dini_IntSet(string, "CollegeChem", Player[playerid][CollegeChem]);
dini_Set(string, "MarriedTo", Player[playerid][MarriedTo]);
dini_IntSet(string, "FightBox", Player[playerid][FightBox]);
dini_IntSet(string, "FightKungfu", Player[playerid][FightKungfu]);
dini_IntSet(string, "FightGrabkick", Player[playerid][FightGrabkick]);
dini_IntSet(string, "FightKneehead", Player[playerid][FightKneehead]);
dini_IntSet(string, "FightElbow", Player[playerid][FightElbow]);
dini_IntSet(string, "VipRank", Player[playerid][VipRank]);
dini_IntSet(string, "WalkieTalkie", Player[playerid][WalkieTalkie]);
dini_IntSet(string, "BankStatus", Player[playerid][BankStatus]);
dini_IntSet(string, "PhoneCredit", Player[playerid][PhoneCredit]);
dini_IntSet(string, "PlayerSkinSlot1", Player[playerid][PlayerSkinSlot1]);
dini_IntSet(string, "PlayerSkinSlot2", Player[playerid][PlayerSkinSlot2]);
dini_IntSet(string, "PlayerSkinSlot3", Player[playerid][PlayerSkinSlot3]);
dini_IntSet(string, "AdminPIN", Player[playerid][AdminPIN]);
dini_Set(string, "AdminName", Player[playerid][AdminName]);
dini_Set(string, "NormalName", Player[playerid][NormalName]);
dini_IntSet(string, "AdminSkin", Player[playerid][AdminSkin]);
dini_Set(string, "Accent", Player[playerid][Accent]);
dini_IntSet(string, "WalkieFrequency", Player[playerid][WalkieFrequency]);
dini_IntSet(string, "PortableRadio", Player[playerid][PortableRadio]);
dini_Set(string, "Note", Player[playerid][Note]);
dini_IntSet(string, "CarPaintJobID", Player[playerid][CarPaintJobID]);
dini_IntSet(string, "MeActions", Player[playerid][MeActions]);
dini_IntSet(string, "AdsPlaced", Player[playerid][AdsPlaced]);
dini_IntSet(string, "MatrunsExecuted", Player[playerid][MatrunsExecuted]);
dini_IntSet(string, "HasMapApp", Player[playerid][HasMapApp]);
dini_IntSet(string, "HasAdApp", Player[playerid][HasAdApp]);
dini_IntSet(string, "HasPagesApp", Player[playerid][HasPagesApp]);
dini_IntSet(string, "HasRadioApp", Player[playerid][HasRadioApp]);
dini_IntSet(string, "AnsweredQuizQuestions", Player[playerid][AnsweredQuizQuestions]);
dini_IntSet(string, "AchievementRank", Player[playerid][AchievementRank]);
dini_IntSet(string, "Tester", Player[playerid][Tester]);
dini_IntSet(string, "oMuted", Player[playerid][oMuted]);
dini_IntSet(string, "PlayerCarModel2", Player[playerid][PlayerCarModel2]);
dini_IntSet(string, "PlayerCarModel3", Player[playerid][PlayerCarModel3]);
dini_FloatSet(string, "Car2ZAngle", Player[playerid][Car2ZAngle]);
dini_FloatSet(string, "Car3ZAngle", Player[playerid][Car3ZAngle]);
dini_IntSet(string, "Car2Col1", Player[playerid][Car2Col1]);
dini_IntSet(string, "Car2Col2", Player[playerid][Car2Col2]);
dini_IntSet(string, "Car3Col1", Player[playerid][Car3Col1]);
dini_IntSet(string, "Car3Col2", Player[playerid][Car3Col2]);
dini_IntSet(string, "Car2PaintJobID", Player[playerid][Car2PaintJobID]);
dini_IntSet(string, "Car3PaintJobID", Player[playerid][Car3PaintJobID]);
dini_FloatSet(string, "Car2X", Player[playerid][Car2X]);
dini_FloatSet(string, "Car2Y", Player[playerid][Car2Y]);
dini_FloatSet(string, "Car2Z", Player[playerid][Car2Z]);
dini_FloatSet(string, "Car3X", Player[playerid][Car3X]);
dini_FloatSet(string, "Car3Y", Player[playerid][Car3Y]);
dini_FloatSet(string, "Car3Z", Player[playerid][Car3Z]);
dini_IntSet(string, "CheckBalance", Player[playerid][CheckBalance]);
dini_IntSet(string, "LockedCar2", Player[playerid][LockedCar2]);
dini_IntSet(string, "LockedCar3", Player[playerid][LockedCar3]);
dini_IntSet(string, "ReportBanStatus", Player[playerid][ReportBanStatus]);
dini_IntSet(string, "AdminDuty", Player[playerid][AdminDuty]);
}
return 1;
}