[HELP] Weapon Skill Command - spyrothedragon96 - 2021-08-03
Hello everyone.
I made 3 commands to set the skill level of the weapons, /poor, /gangster and /hitman.
The problem is that when me and the other players die / disconnect, the level goes back to the initial level, that is to the maximum, and the command I had set is not saved.
How can I do to get it saved when one dies / disconnects?
Quote:COMMAND:poor(playerid, params[])
{
? ? if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "Devi loggare come RCON.");
? ? {
for(new i=0; i<MAX_PLAYERS; i)
{
if(IsPlayerNPC(i) || IsPlayerConnected(i))
{
SetPlayerSkillLevel(i, WEAPONSKILL_PISTOL, 1);
SetPlayerSkillLevel(i, WEAPONSKILL_PISTOL_SILENCED, 1);
SetPlayerSkillLevel(i, WEAPONSKILL_DESERT_EAGLE, 1);
SetPlayerSkillLevel(i, WEAPONSKILL_SHOTGUN, 1);
SetPlayerSkillLevel(i, WEAPONSKILL_SAWNOFF_SHOTGUN, 1);
SetPlayerSkillLevel(i, WEAPONSKILL_SPAS12_SHOTGUN, 1);
SetPlayerSkillLevel(i, WEAPONSKILL_MICRO_UZI, 1);
SetPlayerSkillLevel(i, WEAPONSKILL_MP5, 1);
SetPlayerSkillLevel(i, WEAPONSKILL_AK47, 1);
SetPlayerSkillLevel(i, WEAPONSKILL_M4, 1);
SetPlayerSkillLevel(i, WEAPONSKILL_SNIPERRIFLE, 1);
? ? ? ? }
? ? }
? ? }
return 1;
}
COMMAND:gangster(playerid, params[])
{
? ? if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "Devi loggare come RCON.");
? ? {
for(new i=0; i<MAX_PLAYERS; i)
{
if(IsPlayerNPC(i) || IsPlayerConnected(i))
{
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 40);
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL_SILENCED, 500);
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_DESERT_EAGLE, 200);
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_SHOTGUN, 200);
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 200);
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_SPAS12_SHOTGUN, 200);
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 50);
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_MP5, 250);
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_AK47, 200);
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_M4, 200);
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_SNIPERRIFLE, 300);
? ? ? ? }
? ? }
? ? }
? ? return 1;
}
COMMAND:hitman(playerid, params[])
{
? ? if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "Devi loggare come RCON.");
? ? {
for(new i=0; i<MAX_PLAYERS; i)
{
if(IsPlayerNPC(i) || IsPlayerConnected(i))
{
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 999);
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL_SILENCED, 999);
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_DESERT_EAGLE, 999);
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_SHOTGUN, 999);
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 999);
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_SPAS12_SHOTGUN, 999);
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 999);
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_MP5, 999);
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_AK47, 999);
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_M4, 999);
? ? SetPlayerSkillLevel(playerid, WEAPONSKILL_SNIPERRIFLE, 999);
? ? ? ? }
? ? }
? ? }
? ? return 1;
}
RE: [HELP] Weapon Skill Command - DjSon231 - 2021-08-03
Code: stock WeapSkill_Poor(playerid)
{
SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 1);
SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL_SILENCED, 1);
SetPlayerSkillLevel(playerid, WEAPONSKILL_DESERT_EAGLE, 1);
SetPlayerSkillLevel(playerid, WEAPONSKILL_SHOTGUN, 1);
SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1);
SetPlayerSkillLevel(playerid, WEAPONSKILL_SPAS12_SHOTGUN, 1);
SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 1);
SetPlayerSkillLevel(playerid, WEAPONSKILL_MP5, 1);
SetPlayerSkillLevel(playerid, WEAPONSKILL_AK47, 1);
SetPlayerSkillLevel(playerid, WEAPONSKILL_M4, 1);
SetPlayerSkillLevel(playerid, WEAPONSKILL_SNIPERRIFLE, 1);
return 1;
}
COMMAND:poor(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "Devi loggare come RCON.");
{
for(new i=0; i<MAX_PLAYERS; i)
{
if(!IsPlayerNPC(i) || IsPlayerConnected(i))
{
SetPVarInt(i, "WeapSkill", 1);
WeapSkill_Poor(i);
}
}
}
return 1;
}
You mean, like that?
Try to set PVars - theese are the best for this problems. They are resetting after disconnecting. Define 1 as poor, 2 as gangster, 3 as hitman - and integers in PVars, like in my solution. Next, in OnPlayerSpawn, use WeapSkill_Poor function when PVar "WeapSkill" is set to 1, WeapSkill_Gangster (after you create it) if PVar is set to 2 and so one. If you need to save it after disconnect, use mysql or file manipulation system.
RE: [HELP] Weapon Skill Command - spyrothedragon96 - 2021-08-04
Thank you very much!
|