SA-MP Forums Archive
Help with [faction] OffDuty CMD - 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: Help with [faction] OffDuty CMD (/showthread.php?tid=529649)



Help with [faction] OffDuty CMD - k2rl - 03.08.2014

When a player goes offduty he gets his old skin back, can someone setup a code? -tnx
PHP код:
    else if(dialogid == 5)
    {
        new 
string[128];
        if(
response)
        {
            switch(
listitem)
            {
                case 
0:
                {
                    if(!
PlayerInfo[playerid][pFacDuty])
                    {
                        
PlayerInfo[playerid][pFacDuty] = 1;
                        
SetPlayerColor(playeridTRANSPARENT_BLUE);
                        
format(stringsizeof(string), "* %s grabs their badge, gun and mp5 from the locker."RPN(playerid));
                        
SendNearbyMessage(playerid15stringCOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLE);
                        
GiveDodWeapon(playerid29500);
                        
GiveDodWeapon(playerid24200);
                        
SetPlayerArmour(playerid100);
                        return 
1;
                    }
                    else
                    {
                          
PlayerInfo[playerid][pFacDuty] = 0;
                        
SetPlayerColor(playeridTRANSPARENT_WHITE);
                        
SetPlayerArmour(playerid0);
                        
format(stringsizeof(string), "* %s places their badge in the locker."RPN(playerid));
                        
SendNearbyMessage(playerid15stringCOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLE);
                        return 
1;
                    }
                }
                case 
1:
                {
                    
ShowDialog(playerid6);
                }
                case 
2:
                {
                    
ShowDialog(playerid7);
                }
                case 
3:
                {
                    
ShowDialog(playerid8);
                } 



Re: Help with [faction] OffDuty CMD - David (Sabljak) - 03.08.2014

Make enum for pSkin and save it...

when you placing his "saved" skin use
Код:
SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);



Re: Help with [faction] OffDuty CMD - McBan - 03.08.2014

Implement the following into your saving enum for player data:

Код:
PlayerInfo[playerid][Skin]
Now use the enum to load the player data and to set their skin:

Код:
     SendClientMessage(playerid, 0xFFFFFF, "You Have Gone Off-Duty.");
     SetPlayerSkin(playerid, PlayerInfo[playerid][Skin]);
Edit: Make sure you actually get the players skin before they go On-Duty or else it'll just give them their cop skin back.


Re: Help with [faction] OffDuty CMD - k2rl - 03.08.2014

Quote:
Originally Posted by McBan
Посмотреть сообщение
Implement the following into your saving enum for player data:

Код:
PlayerInfo[playerid][Skin]
Now use the enum to load the player data and to set their skin:

Код:
     SendClientMessage(playerid, 0xFFFFFF, "You Have Gone Off-Duty.");
     SetPlayerSkin(playerid, PlayerInfo[playerid][Skin]);
Edit: Make sure you actually get the players skin before they go On-Duty or else it'll just give them their cop skin back.
A bit more help? Kinda New..


Re: Help with [faction] OffDuty CMD - McBan - 03.08.2014

Right. Well let me do it for you.

PHP код:
new oldskin
The above is a Global Variable, Can be used anywhere in the script.

PHP код:
oldskin PlayerInfo[playerid][Skin
The above defines that the variable oldskin is equal to whatever skin ID the player has.

PHP код:
SetPlayerSkin(playeridoldskin); 
The above sets the player skin to the variable "oldskin". Which as you should know, is equal to the Skin ID the player was assigned when he typed the command.

So:

PHP код:
new oldskin;
else if(
dialogid == 5
    { 
        new 
string[128]; 
        if(
response
        { 
            switch(
listitem
            { 
                case 
0
                { 
                    if(!
PlayerInfo[playerid][pFacDuty]) 
                    {
                        
oldskin PlayerInfo[playerid][Skin]
                        
PlayerInfo[playerid][pFacDuty] = 1
                        
SetPlayerColor(playeridTRANSPARENT_BLUE); 
                        
format(stringsizeof(string), "* %s grabs their badge, gun and mp5 from the locker."RPN(playerid)); 
                        
SendNearbyMessage(playerid15stringCOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLE); 
                        
GiveDodWeapon(playerid29500); 
                        
GiveDodWeapon(playerid24200); 
                        
SetPlayerArmour(playerid100); 
                        return 
1
                    } 
                    else 
                    { 
                        
SetPlayerSkin(playeridoldskin);
                        
PlayerInfo[playerid][pFacDuty] = 0
                        
SetPlayerColor(playeridTRANSPARENT_WHITE); 
                        
SetPlayerArmour(playerid0); 
                        
format(stringsizeof(string), "* %s places their badge in the locker."RPN(playerid)); 
                        
SendNearbyMessage(playerid15stringCOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLE); 
                        return 
1
                    } 
                } 
                case 
1
                { 
                    
ShowDialog(playerid6); 
                } 
                case 
2
                { 
                    
ShowDialog(playerid7); 
                } 
                case 
3
                { 
                    
ShowDialog(playerid8); 
                } 



Re: Help with [faction] OffDuty CMD - k2rl - 03.08.2014

Quote:
Originally Posted by McBan
Посмотреть сообщение
Right. Well let me do it for you.

PHP код:
new oldskin
The above is a Global Variable, Can be used anywhere in the script.

PHP код:
oldskin PlayerInfo[playerid][Skin
The above defines that the variable oldskin is equal to whatever skin ID the player has.

PHP код:
SetPlayerSkin(playeridoldskin); 
The above sets the player skin to the variable "oldskin". Which as you should know, is equal to the Skin ID the player was assigned when he typed the command.

So:

PHP код:
new oldskin;
else if(
dialogid == 5
    { 
        new 
string[128]; 
        if(
response
        { 
            switch(
listitem
            { 
                case 
0
                { 
                    if(!
PlayerInfo[playerid][pFacDuty]) 
                    {
                        
oldskin PlayerInfo[playerid][Skin]
                        
PlayerInfo[playerid][pFacDuty] = 1
                        
SetPlayerColor(playeridTRANSPARENT_BLUE); 
                        
format(stringsizeof(string), "* %s grabs their badge, gun and mp5 from the locker."RPN(playerid)); 
                        
SendNearbyMessage(playerid15stringCOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLE); 
                        
GiveDodWeapon(playerid29500); 
                        
GiveDodWeapon(playerid24200); 
                        
SetPlayerArmour(playerid100); 
                        return 
1
                    } 
                    else 
                    { 
                        
SetPlayerSkin(playeridoldskin);
                        
PlayerInfo[playerid][pFacDuty] = 0
                        
SetPlayerColor(playeridTRANSPARENT_WHITE); 
                        
SetPlayerArmour(playerid0); 
                        
format(stringsizeof(string), "* %s places their badge in the locker."RPN(playerid)); 
                        
SendNearbyMessage(playerid15stringCOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLE); 
                        return 
1
                    } 
                } 
                case 
1
                { 
                    
ShowDialog(playerid6); 
                } 
                case 
2
                { 
                    
ShowDialog(playerid7); 
                } 
                case 
3
                { 
                    
ShowDialog(playerid8); 
                } 
Thank you mate! you are the best but one thing :/

PHP код:
(24142) : error 001expected token";"but found "else"
(24142) : error 029invalid expressionassumed zero
(24142) : warning 215expression has no effect
(24142) : error 001expected token";"but found "if"
(24142) : fatal error 107too many error messages on one line 



Re: Help with [faction] OffDuty CMD - SlimDkhili - 03.08.2014

line ?


Re: Help with [faction] OffDuty CMD - k2rl - 03.08.2014

Quote:
Originally Posted by SlimDkhili
Посмотреть сообщение
line ?
(24141)else if(dialogid == 5);
(24142) {
(24143) new string[128];
(24144) if(response)
(24145) {


Re: Help with [faction] OffDuty CMD - SlimDkhili - 03.08.2014

else if(dialogid == 5);
delete it if it existe


Re: Help with [faction] OffDuty CMD - k2rl - 03.08.2014

Quote:
Originally Posted by SlimDkhili
Посмотреть сообщение
else if(dialogid == 5);
delete it if it existe
Still the same error :/
the full thing here:
PHP код:
new oldskin
else if(dialogid == 5)
    {
        new 
string[128]
        if(
response)
        {
            switch(
listitem)
            {
                case 
0:
                {
                    if(!
PlayerInfo[playerid][pFacDuty])
                    {
                        
oldskin PlayerInfo[playerid][Skin]
                        
PlayerInfo[playerid][pFacDuty] = 1;
                        
SetPlayerColor(playeridTRANSPARENT_BLUE);
                        
format(stringsizeof(string), "* %s grabs their badge, gun and mp5 from the locker."RPN(playerid));
                        
SendNearbyMessage(playerid15stringCOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLE);
                        
GiveDodWeapon(playerid29500);
                        
GiveDodWeapon(playerid24200);
                        
SetPlayerArmour(playerid100);
                        return 
1;
                    }
                    else
                    {
                        
SetPlayerSkin(playeridoldskin);
                        
PlayerInfo[playerid][pFacDuty] = 0;
                        
SetPlayerColor(playeridTRANSPARENT_WHITE);
                        
SetPlayerArmour(playerid0);
                        
format(stringsizeof(string), "* %s places their badge in the locker."RPN(playerid));
                        
SendNearbyMessage(playerid15stringCOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLE);
                        return 
1;
                    }
                }
                case 
1:
                {
                    
ShowDialog(playerid6);
                }
                case 
2:
                {
                    
ShowDialog(playerid7);
                }
                case 
3:
                {
                    
ShowDialog(playerid8);
                }