SA-MP Forums Archive
Save/Get previous 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: Save/Get previous weapons. (/showthread.php?tid=536970)



Save/Get previous weapons. - PawnOX - 13.09.2014

I wonder if i can make, Save/Get previous weapons. Whats the code


Re: Save/Get previous weapons. - amirab - 13.09.2014

search in ******
there's alot of script like that you want


Re: Save/Get previous weapons. - IamPRO - 13.09.2014

Try it http://pastebin.com/TaD5miwQ.


Re: Save/Get previous weapons. - SickAttack - 13.09.2014

Quote:
Originally Posted by IamPRO
Посмотреть сообщение
Well, that's a bad script.


Re: Save/Get previous weapons. - PawnOX - 13.09.2014

i mean, when player is admin off duty then he /aduty to get on duty, it will save his previous weapons then if he go admin off duty again the previous weapon will load. Is that possible?


Re: Save/Get previous weapons. - KayJ - 13.09.2014

Quote:
Originally Posted by PawnOX
Посмотреть сообщение
i mean, when player is admin off duty then he /aduty to get on duty, it will save his previous weapons then if he go admin off duty again the previous weapon will load. Is that possible?
do you make codes for that?


Re: Save/Get previous weapons. - PawnOX - 13.09.2014

Quote:
Originally Posted by SturtIndia
Посмотреть сообщение
do you make codes for that?
Here
pawn Код:
CMD:aduty(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, -1, "This is an admin only command!");
    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        if(PlayerInfo[playerid][pAdminDuty] == 0)
        {

        SendClientMessageEx(playerid, COLOR_BLUE, "You are now on Administrator duty! !");
        //SetPlayerName(playerid, PlayerInfo[playerid][pAdminName]);
        PlayerInfo[playerid][pAdminDuty] = 1;

        SetPlayerHealth(playerid, 100000);
        SetPlayerArmour(playerid, 100000);
        //SetPlayerColor(playerid, COLOR_TWORANGE);
        SetPlayerColor(playerid, COLOR_REALRED);
        GivePlayerWeapon(playerid, 24, 99999);
        GivePlayerWeapon(playerid, 43, 60000);
        GivePlayerWeapon(playerid, 24, 60000);
        GivePlayerWeapon(playerid, 31, 99999);
        GivePlayerWeapon(playerid, 32, 99999);
        GivePlayerWeapon(playerid, 27, 99999);
        GivePlayerWeapon(playerid, 34, 99999);
        if(PlayerInfo[playerid][pAdmin] >= 1) {
        GivePlayerWeapon(playerid, 38, 99999);
        }
        new szMessage[47 + (MAX_PLAYER_NAME * 2)];
        format(szMessage, sizeof(szMessage), "Administrator %s is now ON Duty!", GetPlayerNameEx(playerid));
        //ABroadCast(COLOR_YELLOW,szMessage, 2);

        SendClientMessageToAllEx(COLOR_REALRED, szMessage);
        }
        else
        {
        SendClientMessageEx(playerid, COLOR_BLUE, "You are now off admin duty!");
        //SetPlayerName(playerid, PlayerInfo[playerid][pNormalName]);
        SetPlayerHealth(playerid, 100);
        SetPlayerArmour(playerid, 0);
        RemovePlayerWeapon(playerid, 24);
        RemovePlayerWeapon(playerid, 43);
        RemovePlayerWeapon(playerid, 46);
        RemovePlayerWeapon(playerid, 24);
        RemovePlayerWeapon(playerid, 31);
        RemovePlayerWeapon(playerid, 32);
        RemovePlayerWeapon(playerid, 27);
        RemovePlayerWeapon(playerid, 34);
        SetPlayerToTeamColor(playerid);
        Delete3DTextLabel(DutyLabel[playerid]);
        //SetPlayerSkin(playerid, 299); - Commented by Voltage
        PlayerInfo[playerid][pAdminDuty] = 0;
        new szMessage[47 + (MAX_PLAYER_NAME * 2)];
        format(szMessage, sizeof(szMessage), "Administrator %s is now OFF Duty!", GetPlayerNameEx(playerid));
        //format(szMessage, sizeof(szMessage), "AdmCmd: Administrator %s is now Off Duty!", GetPlayerNameEx(playerid));
    //  ABroadCast(COLOR_YELLOW,szMessage, 2);
        SendClientMessageToAllEx(COLOR_REALRED, szMessage);
        }
    }
    return 1;
}



Re: Save/Get previous weapons. - JM_Millers - 13.09.2014

Quote:
Originally Posted by PawnOX
Посмотреть сообщение
i mean, when player is admin off duty then he /aduty to get on duty, it will save his previous weapons then if he go admin off duty again the previous weapon will load. Is that possible?
At first:
pawn Код:
new
    weap[MAX_PLAYERS][12 char],
    ammo[MAX_PLAYERS][12]
;

savePlayerGuns(p)
{
    for(new i=sizeof ammo[]; i != 0; i--)
    {
        GetPlayerWeaponData(p, i, weap[p][i],ammo[p][i]);
    }
    return true;
}

loadPlayerGuns(p)
{
    for(new i=sizeof ammo[]; i != 0; i--)
    {
        if !weap[playerid][i] *then continue;
        GivePlayerWeapon(playerid, weap[p][i],ammo[p][i]);
    }
}
/aduty on (before you give him admin weapons):
pawn Код:
savePlayerGuns(.p=playerid);
/aduty off (at the end og the command):
pawn Код:
loadPlayerGuns(.p=playerid);



Re: Save/Get previous weapons. - KayJ - 13.09.2014

pawn Код:
CMD:aduty(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, -1, "This is an admin only command!");
    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        if(PlayerInfo[playerid][pAdminDuty] == 0)
        {

        SendClientMessageEx(playerid, COLOR_BLUE, "You are now on Administrator duty! !");
        //SetPlayerName(playerid, PlayerInfo[playerid][pAdminName]);
        PlayerInfo[playerid][pAdminDuty] = 1;

        SetPlayerHealth(playerid, 100000);
        SetPlayerArmour(playerid, 100000);
        //SetPlayerColor(playerid, COLOR_TWORANGE);
        SetPlayerColor(playerid, COLOR_REALRED);
        ResetPlayerWeapons(killerid);
        GivePlayerWeapon(playerid, 24, 99999);
        GivePlayerWeapon(playerid, 43, 60000);
        GivePlayerWeapon(playerid, 24, 60000);
        GivePlayerWeapon(playerid, 31, 99999);
        GivePlayerWeapon(playerid, 32, 99999);
        GivePlayerWeapon(playerid, 27, 99999);
        GivePlayerWeapon(playerid, 34, 99999);
        if(PlayerInfo[playerid][pAdmin] >= 1) {
        GivePlayerWeapon(playerid, 38, 99999);
        }
        new szMessage[47 + (MAX_PLAYER_NAME * 2)];
        format(szMessage, sizeof(szMessage), "Administrator %s is now ON Duty!", GetPlayerNameEx(playerid));
        ABroadCast(COLOR_YELLOW,szMessage, 2);

        SendClientMessageToAllEx(COLOR_REALRED, szMessage);
        }
        else
        {
        SendClientMessageEx(playerid, COLOR_BLUE, "You are now off admin duty!");
        SpawnPlayer(playerid);
        //SetPlayerName(playerid, PlayerInfo[playerid][pNormalName]);
        SetPlayerHealth(playerid, 100);
        SetPlayerArmour(playerid, 0);
        ResetPlayerWeapons(killerid);
        SetPlayerToTeamColor(playerid);
        Delete3DTextLabel(DutyLabel[playerid]);
        SetPlayerSkin(playerid, 299); - Commented by Voltage
        PlayerInfo[playerid][pAdminDuty] = 0;
        new szMessage[47 + (MAX_PLAYER_NAME * 2)];
        format(szMessage, sizeof(szMessage), "Administrator %s is now OFF Duty!", GetPlayerNameEx(playerid));
        format(szMessage, sizeof(szMessage), "AdmCmd: Administrator %s is now Off Duty!", GetPlayerNameEx(playerid));
        ABroadCast(COLOR_YELLOW,szMessage, 2);
        SendClientMessageToAllEx(COLOR_REALRED, szMessage);
        }
    }
    return 1;
}
It will spawn player again after offduty and I made some changes also


Re: Save/Get previous weapons. - PawnOX - 13.09.2014

Quote:
Originally Posted by JM_Millers
Посмотреть сообщение
At first:
pawn Код:
new
    weap[MAX_PLAYERS][12 char],
    ammo[MAX_PLAYERS][12]
;

savePlayerGuns(p)
{
    for(new i=sizeof ammo[]; i != 0; i--)
    {
        GetPlayerWeaponData(p, i, weap[p][i],ammo[p][i]);
    }
    return true;
}

loadPlayerGuns(p)
{
    for(new i=sizeof ammo[]; i != 0; i--)
    {
        if !weap[playerid][i] *then continue;
        GivePlayerWeapon(playerid, weap[p][i],ammo[p][i]);
    }
}
/aduty on (before you give him admin weapons):
pawn Код:
savePlayerGuns(.p=playerid);
/aduty off (at the end og the command):
pawn Код:
loadPlayerGuns(.p=playerid);
Код:
(93221) : warning 219: local variable "ammo" shadows a variable at a preceding level
 : warning 203: symbol is never used: "loadPlayerGuns"
 : warning 203: symbol is never used: "savePlayerGuns"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Warnings.