Help with [faction] OffDuty CMD
#1

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);
                } 
Reply
#2

Make enum for pSkin and save it...

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

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.
Reply
#4

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..
Reply
#5

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); 
                } 
Reply
#6

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 
Reply
#7

line ?
Reply
#8

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

else if(dialogid == 5);
delete it if it existe
Reply
#10

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);
                } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)