/duty command
#1

i have made a duty command. but when i go off duty i need the weps i had before i went to duty. please help. thnks
Reply
#2

Can we see a snippet of your code ? We're not mind readers lolz.
Reply
#3

Uhmm like Stigg said. Provide some code.
Reply
#4

when i go back to off duty. i want wat skin i used before and weps
Code:
dcmd_onduty(playerid,params[])
{
    #pragma unused params
	if (AccInfo[playerid][Level] >= 1)
	{
	    if(AccInfo[playerid][OnDuty] == 0)
	    {
 			AccInfo[playerid][OnDuty] = 1;
 			SetPlayerHealth(playerid,100000);
 			SetPlayerSkin(playerid,294);
			GivePlayerWeapon(playerid,16,50000);
			GivePlayerWeapon(playerid,38,50000);
 			return SendClientMessage(playerid,green,"You are now in Duty Mode");
		}
		else
		{
			AccInfo[playerid][OnDuty] = 0;
			SetPlayerHealth(playerid,100);
 			return SendClientMessage(playerid,orange,"You are now Off Duty");
 			
		}
	}
	return ErrorMessages(playerid, 5);
}
Reply
#5

For skin you could do it with PVar's like this:

pawn Code:
dcmd_onduty(playerid,params[])
{
    #pragma unused params
    if (AccInfo[playerid][Level] >= 1)
    {
        if(AccInfo[playerid][OnDuty] == 0)
        {
            SetPVarInt(playerid, "Skin", GetPlayerSkin(playerid)); // added
           
            AccInfo[playerid][OnDuty] = 1;
            SetPlayerHealth(playerid,100000);
            SetPlayerSkin(playerid,294);
            GivePlayerWeapon(playerid,16,50000);
            GivePlayerWeapon(playerid,38,50000);
            return SendClientMessage(playerid,green,"You are now in Duty Mode");
        }
        else
        {
            SetPlayerSkin(playerid, GetPVarInt(playerid, "Skin")); // Added
           
            AccInfo[playerid][OnDuty] = 0;
            SetPlayerHealth(playerid,100);
            return SendClientMessage(playerid,orange,"You are now Off Duty");
           
        }
    }
    return ErrorMessages(playerid, 5);
}
Reply
#6

Like mmrk did, you can use PVar's. You can also use variables to store the player's last weapons/skin too. Here, try storing the weapons in a variable this time instead of PVars:

pawn Code:
// top of script

new WepBeforeDuty[MAX_PLAYERS];

// place this in your /onduty script BEFORE the player gets the minigun and other weapons

WepBeforeDuty[playerid] = GetPlayerWeapons(playerid);

// when the player types /onduty again (to go off duty)

GivePlayerWeapon(playerid,WepBeforeDuty[playerid]);
The above should give you the weapons they had before (maybe the exact same ammo too but I don't know for sure).

All together, the /onduty command should look like this:
pawn Code:
dcmd_onduty(playerid,params[])
{
    #pragma unused params
    if (AccInfo[playerid][Level] >= 1)
    {
        if(AccInfo[playerid][OnDuty] == 0)
        {
            SetPVarInt(playerid, "Skin", GetPlayerSkin(playerid)); // added
           
            AccInfo[playerid][OnDuty] = 1;
            SetPlayerHealth(playerid,100000);
            SetPlayerSkin(playerid,294);
            WepBeforeDuty[playerid] = GetPlayerWeapons(playerid); // getting their weps BEFORE it sets to minigun
            GivePlayerWeapon(playerid,16,50000);
            GivePlayerWeapon(playerid,38,50000);
            return SendClientMessage(playerid,green,"You are now in Duty Mode");
        }
        else
        {
            SetPlayerSkin(playerid, GetPVarInt(playerid, "Skin")); // Added
            GivePlayerWeapon(playerid,WepBeforeDuty[playerid]); // giving the weapons back that we used above ^
            AccInfo[playerid][OnDuty] = 0;
            SetPlayerHealth(playerid,100);
            return SendClientMessage(playerid,orange,"You are now Off Duty");
           
        }
    }
    return ErrorMessages(playerid, 5);
}
Reply
#7

getting errors
Code:
C:\Users\script\new script\filterscripts\newscript.pwn(6067) : error 017: undefined symbol "WepBeforeDuty"
C:\Users\script\new script\filterscripts\newscript.pwn(6067) : warning 215: expression has no effect
C:\Users\script\new script\filterscripts\newscript.pwn(6067) : error 001: expected token: ";", but found "]"
C:\Users\script\new script\filterscripts\newscript.pwn(6067) : error 029: invalid expression, assumed zero
C:\Users\script\new script\filterscripts\newscript.pwn(6067) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#8

Did you put :

new WepBeforeDuty[MAX_PLAYERS];

at the top of the script (under #include <a_samp>)
Reply
#9

still getting this errors
Code:
C:\Users\script\new script\filterscripts\newscript.pwn(34) : error 010: invalid function or declaration
C:\Users\script\new script\filterscripts\newscript.pwn(6068) : error 017: undefined symbol "WepBeforeDuty"
C:\Users\script\new script\filterscripts\newscript.pwn(6068) : warning 215: expression has no effect
C:\Users\script\new script\filterscripts\newscript.pwn(6068) : error 001: expected token: ";", but found "]"
C:\Users\script\new script\filterscripts\newscript.pwn(6068) : error 029: invalid expression, assumed zero
C:\Users\script\new script\filterscripts\newscript.pwn(6068) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.
Reply
#10

Hey ThamburaaN.

Here is /AdminDutyON and /AdminDutyOFF code:-

I have made by myself.

You must #include <zcmd>

Top of your fs.

pawn Code:

new AdminOnDuty[MAX_PLAYERS]


And here is the code:-

pawn Code:

pawn Code:
CMD:admindutyon(playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    if(AdminOnDuty[playerid] == 1) return SendClientMessage(playerid,0xAA3333AA, "You're already on Adminstrator duty, Type /AdminDutyOff to OFF your duty!");
    else
    {
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    new string[128];
    AdminOnDuty[playerid] = 1;
    format(string,sizeof(string), "Adminstrator %s is now on Admin duty.", pName);
    SendClientMessageToAll(0x33CCFFAA, string);
    }
    else
    {
    SendClientMessage(playerid, 0xAA3333AA, "You're not an adminstrator to use this cmd");
    }
    return 1;
}

CMD:admindutyoff(playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    if(AdminOnDuty[playerid] == 0) return SendClientMessage(playerid,0xAA3333AA, "You're already off Adminstrator Duty, Type /AdminDutyOn to ON your duty!");
    else
    {
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    new string[128];
    AdminOnDuty[playerid] = 0;
    format(string,sizeof(string), "Adminstrator %s is no longer on Adminstrator duty.", pName);
    SendClientMessageToAll(0x33CCFFAA, string);
    }
    else
    {
    SendClientMessage(playerid, 0xAA3333AA, "You're not an adminstrator to use this cmd");
    }
    return 1;
}

You must be /Rcon (Password) to use this command, or you can change it to your admin level fs.



Well i hope this works.


Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)