SA-MP Forums Archive
Saving Weapons - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Saving Weapons (/showthread.php?tid=646405)



Saving Weapons - Uvais - 16.12.2017

Hey, Can anyone tell me a way to save a players original weapons before /onduty and give them back at /offduty ?
I was successful with everything including health, armour, skin , color, and team but not weapons. Any help would be appreciated.


Re: Saving Weapons - Logic_ - 16.12.2017

GetPlayerWeaponData, a loop of 12, and a 2-dimensional variable with-in a global array:

EDIT: This should help you out: http://forum.sa-mp.com/showpost.php?...99&postcount=2


Re: Saving Weapons - Uvais - 16.12.2017

Can you give me an example, I didn't quite understand.. This is my command

PHP код:
CMD:aduty(playerid,params[])
{
    new 
string[128];
    if (
PInfo[playerid][Admin] < 1) return SendClientMessage(playeridRED,"[ERROR]: {FFFFFF}You do not have the privilleges to perform this command.");
    if(
AdminDuty[playerid] == 0)
    {
        
oldteam[playerid] = GetPlayerTeam(playerid);
        
oldcolor[playerid] = GetPlayerColor(playerid);
        
oldskin[playerid] = GetPlayerSkin(playerid);
        
oldhealth[playerid] = GetPlayerHealth(playerid);
        
oldarmour[playerid] = GetPlayerArmour(playerid);
        
ResetPlayerWeapons(playerid);
        
        
format(string,sizeof(string),"[ADMIN DUTY]: {FFFFFF}Administrator %s is now in on-duty admin mode.",GetName(playerid));
        
SendClientMessageToAll(COLOR_ADMIN,string);
        
SetPlayerHealth(playerid500000);
        
SetPlayerColor(playerid,PINK);
        
SetPlayerSkin(playerid217);
        
GivePlayerWeapon(playerid38999999);
        
AdminDuty[playerid] = 1;
        
SetPlayerTeam(playeridTEAM_NONE);
        
adminlabel[playerid] = Create3DTextLabel("Admin on duty\n Do Not Attack!"RED30.040.050.040.00);
        
Attach3DTextLabelToPlayer(adminlabel[playerid], playerid0.00.00.7);
    }
    else
    if(
AdminDuty[playerid] == 1)
    {
        
format(string,sizeof(string),"[ADMIN DUTY]: {FFFFFF}Administrator %s is no longer in on-duty admin mode.",GetName(playerid));
        
SendClientMessageToAll(COLOR_ADMIN,string);
        
AdminDuty[playerid] = 0;
        
ResetPlayerWeapons(playerid);
        
adminlabel[playerid] = Create3DTextLabel("Admin on duty\n Do Not Attack!"RED30.040.050.040.00);
        
Delete3DTextLabel(adminlabel[playerid]);
        
SetPlayerHealth(playeridoldhealth[playerid]);
        
SetPlayerArmour(playeridoldarmour[playerid]);
        
SetPlayerSkin(playeridoldskin[playerid]);
        
SetPlayerTeam(playeridoldteam[playerid]);
        
SetPlayerColor(playeridoldcolor[playerid]);
    }
    return 
1;




Re: Saving Weapons - Logic_ - 16.12.2017

In an indirect way you're telling me to give you the code for it, which I won't, the thread which I linked you to, already explains and does that, you just need to change the variable to global from local. And if you still don't get what local and global variables are, then I'm sorry but you need to read the SA-MP wiki.


Re: Saving Weapons - Hunud - 16.12.2017

@Uvais, this section was made to help peoples for their bad/miss.u of code. Not to code for them.


Re: Saving Weapons - Uvais - 16.12.2017

Thanks for the help.