enum E_gunVars
{
gunID,
gunAmmo,
Float:gunPos[4],
gunVirtualWorld,
gunInterior
}
new
droppedWepInfo[MAX_DROPPED_WEAPONS][E_gunVars],
WeaponPID[MAX_DROPPED_WEAPONS];
OnGameModeInit -
for( new w; w < MAX_DROPPED_WEAPONS; w++ )
{
format(wepStr, sizeof(wepStr), "RPMod/Weapons/%d.ini", w);
if(fexist(wepStr))
{
INI_ParseFile(wepStr, "LoadWeapon_%s", .bExtra = true, .extra = w);
WeaponPID[w] = CreateDynamicObject(GetWeaponObjectID(droppedWepInfo[w][gunID]), droppedWepInfo[w][gunPos][0], droppedWepInfo[w][gunPos][1], droppedWepInfo[w][gunPos][2]-1, 0.0, 0.0, 0.0, droppedWepInfo[w][gunVirtualWorld]);
printf("[LOAD] Dropped Weapon ID %d loaded. Weapon ID: %d | Ammo: %d", w, droppedWepInfo[w][gunID], droppedWepInfo[w][gunAmmo]);
}
}
OnGameModeExit -
for( new w; w < MAX_DROPPED_WEAPONS; w++ )
{
format(wepStr, sizeof(wepStr), "RPMod/Weapons/%d.ini", w);
if(fexist(wepStr))
{
new
INI:wepFile = INI_Open(wepStr);
INI_SetTag(wepFile, "weapon");
INI_WriteInt(wepFile, "WeaponID", droppedWepInfo[w][gunID]);
INI_WriteInt(wepFile, "WeaponAmmo", droppedWepInfo[w][gunAmmo]);
INI_WriteFloat(wepFile, "WeaponX", droppedWepInfo[w][gunPos][0]);
INI_WriteFloat(wepFile, "WeaponY", droppedWepInfo[w][gunPos][1]);
INI_WriteFloat(wepFile, "WeaponZ", droppedWepInfo[w][gunPos][2]);
INI_WriteFloat(wepFile, "WeaponA", droppedWepInfo[w][gunPos][3]);
INI_WriteInt(wepFile, "WeaponVirtualWorld", droppedWepInfo[w][gunVirtualWorld]);
INI_WriteInt(wepFile, "WeaponInterior", droppedWepInfo[w][gunInterior]);
INI_Close(wepFile);
DestroyDynamicObject(WeaponPID[w]);
}
}
CMD:dropwep(playerid, params[])
{
new
Float:wepPos[4],
WeaponID,
fID = GetOpenWeaponID(),
WeaponAmmo,
wepStr[32],
sendStr[128],
p_Name[MAX_PLAYER_NAME]
;
if(GetPlayerWeapon(playerid) != 0 && GetPlayerAmmo(playerid) != 0) //If they have a weapon..
{
GetPlayerPos(playerid, wepPos[0], wepPos[1], wepPos[2]);
GetPlayerFacingAngle(playerid, wepPos[3]);
WeaponID = GetPlayerWeapon(playerid);
WeaponAmmo = GetPlayerAmmo(playerid);
GetPlayerName(playerid, p_Name, sizeof(p_Name));
format(wepStr, sizeof(wepStr), "RPMod/Weapons/%d.ini", fID);
if(!fexist(wepStr))
{
new
INI:wepFile = INI_Open(wepStr);
INI_SetTag(wepFile, "weapon");
INI_WriteInt(wepFile, "WeaponID", WeaponID);
INI_WriteInt(wepFile, "WeaponAmmo", WeaponAmmo);
INI_WriteFloat(wepFile, "WeaponX", wepPos[0]);
INI_WriteFloat(wepFile, "WeaponY", wepPos[1]);
INI_WriteFloat(wepFile, "WeaponZ", wepPos[2]);
INI_WriteFloat(wepFile, "WeaponA", wepPos[3]);
INI_WriteInt(wepFile, "WeaponVirtualWorld", GetPlayerVirtualWorld(playerid));
INI_WriteInt(wepFile, "WeaponInterior", GetPlayerInterior(playerid));
INI_Close(wepFile);
LoadWeapons();
WeaponPID[fID] = CreateDynamicObject(GetWeaponObjectID(droppedWepInfo[fID][gunID]), droppedWepInfo[fID][gunPos][0], droppedWepInfo[fID][gunPos][1], droppedWepInfo[fID][gunPos][2]-1, 80.0, 0.0, 0.0, droppedWepInfo[fID][gunVirtualWorld]);
printf("Test: %d | %d",fID,WeaponPID[fID]);
format(sendStr, sizeof(sendStr), ""#PURPLE"* "#LIME"%s "#PURPLE"has dropped a weapon.", p_Name);
ProxDetector(20.0, playerid, sendStr, c_PURPLE, c_PURPLE, c_PURPLE, c_PURPLE, c_PURPLE);
RemovePlayerWeapon(playerid, WeaponID);
}
}
return 1;
}
for( new w; w < MAX_DROPPED_WEAPONS; w++ )
{
if(IsPlayerInRangeOfPoint(playerid, 1, droppedWepInfo[w][gunPos][0], droppedWepInfo[w][gunPos][1], droppedWepInfo[w][gunPos][2]))
{
if(GetPlayerVirtualWorld(playerid) == droppedWepInfo[w][gunVirtualWorld] && GetPlayerInterior(playerid) == droppedWepInfo[w][gunInterior])
{
new
wepStr[32];
format(wepStr, sizeof(wepStr), "RPMod/Weapons/%d.ini", w);
GivePlayerWeapon(playerid, droppedWepInfo[w][gunID], droppedWepInfo[w][gunAmmo]);
DestroyDynamicObject(WeaponPID[w]);
printf("%d", WeaponPID[w]);
fremove(wepStr);
LoadWeapons();
}
}
}
forward LoadWeapon_weapon(wepid, name[], value[]);
public LoadWeapon_weapon(wepid, name[], value[])
{
INI_Int("WeaponID", droppedWepInfo[wepid][gunID]);
INI_Int("WeaponAmmo", droppedWepInfo[wepid][gunAmmo]);
INI_Float("WeaponX", droppedWepInfo[wepid][gunPos][0]);
INI_Float("WeaponY", droppedWepInfo[wepid][gunPos][1]);
INI_Float("WeaponZ", droppedWepInfo[wepid][gunPos][2]);
INI_Float("WeaponA", droppedWepInfo[wepid][gunPos][3]);
INI_Int("WeaponVirtualWorld", droppedWepInfo[wepid][gunVirtualWorld]);
INI_Int("WeaponInterior", droppedWepInfo[wepid][gunInterior]);
return true;
}
stock LoadWeapons()
{
new
wepStr[32];
for( new w = 1; w < MAX_DROPPED_WEAPONS; w++ ) //Reload weapons!
{
format(wepStr, sizeof(wepStr), "RPMod/Weapons/%d.ini", w);
if(fexist(wepStr))
{
INI_ParseFile(wepStr, "LoadWeapon_%s", .bExtra = true, .extra = w);
}
}
return true;
}
tl;dr. Just explain BRIEFLY what the problem is and show the absolutley RELEVANT code, not your entire gamemode.
|
You never actually reset any info in your enum, you just update it. If the file doesn't exist, then you need to reset/delete the info in the enum for that file/weapon
|
droppedWepInfo[some index][some index][0] = 0
droppedWepInfo[some index][some index][1] = 0
//etc