Attachment systen [Help]
#1

I'm having trouble on finding away to save the attment objects to players after they leave the server, is there any sort of system i can use along the lines of this

PHP код:
#define PATH "/ZMA/Users/%s.ini" 
It's just so players don't have to re-attach there objects every time they enter the server.

Any help thats given will be greatly apprichated.



PHP код:

    
//Player Attachments system by Excel
    //==============================================================================
    #include <a_samp>
    #include <mSelection>
    #include <sscanf2>
    #include <dini>
    #include <zcmd>
    //==============================================================================
    #define DIALOG_ATTACH_INDEX             13500
    #define DIALOG_ATTACH_INDEX_SELECTION   DIALOG_ATTACH_INDEX+1
    #define DIALOG_ATTACH_EDITREPLACE       DIALOG_ATTACH_INDEX+2
    #define DIALOG_ATTACH_MODEL_SELECTION   DIALOG_ATTACH_INDEX+3
    #define DIALOG_ATTACH_BONE_SELECTION    DIALOG_ATTACH_INDEX+4
    #define DIALOG_ATTACH_OBJECT_SELECTION  DIALOG_ATTACH_INDEX+5
    #define DIALOG_ATTACH_OBJECT2_SELECTION DIALOG_ATTACH_INDEX+6
    //==============================================================================
    #define MAX_OSLOTS  MAX_PLAYER_ATTACHED_OBJECTS
    //==============================================================================
    #define         COL_WHITE       "{FFFFFF}"
    #define         COL_BLACK       "{0E0101}"
    #define         COL_GREY        "{C3C3C3}"
    #define         COL_GREEN       "{6EF83C}"
    #define         COL_RED         "{F81414}"
    #define         COL_YELLOW      "{F3FF02}"
    #define         COL_ORANGE      "{FFAF00}"
    #define         COL_LIME        "{B7FF00}"
    #define         COL_CYAN        "{00FFEE}"
    #define         COL_BLUE        "{0049FF}"
    #define         COL_MAGENTA     "{F300FF}"
    #define         COL_VIOLET      "{B700FF}"
    #define         COL_PINK        "{FF00EA}"
    #define         COL_MARONE      "{A90202}"
    //==============================================================================
    
new AttachmentObjectsList[] = {
    
339,
    
348,
    
355,
    
356,
    
357,
    
358,
    
368,
    
19141,
    
19142,
    
19541,
    
19515,
    
18654,
    
18977,
    
18978,
    
18979,
    
18895,
    
18896,
    
18962,
    
19064,
    
18911,
    
18912,
    
18918,
    
    };
    
//==============================================================================
    
new AttachmentBones[][24] = {
    {
"Spine"},
    {
"Head"},
    {
"Left upper arm"},
    {
"Right upper arm"},
    {
"Left hand"},
    {
"Right hand"},
    {
"Left thigh"},
    {
"Right thigh"},
    {
"Left foot"},
    {
"Right foot"},
    {
"Right calf"},
    {
"Left calf"},
    {
"Left forearm"},
    {
"Right forearm"},
    {
"Left clavicle"},
    {
"Right clavicle"},
    {
"Neck"},
    {
"Jaw"}
    };
    
//==============================================================================
    
CMD:o(playerid,params[])
    {
            new 
string[128];
            new 
dialog[500];
            for(new 
x;x<MAX_OSLOTS;x++)
            {
            if(
IsPlayerAttachedObjectSlotUsed(playeridx))
                    {       
format(stringsizeof(string), ""COL_WHITE"Slot:%d :: "COL_GREEN"Used Slot\n"x);    }
                    else 
format(stringsizeof(string), ""COL_WHITE"Slot:%d\n"x);
                    
strcat(dialog,string);
            }
            
ShowPlayerDialog(playeridDIALOG_ATTACH_INDEX_SELECTIONDIALOG_STYLE_LIST,"Player Objects/Attachment: (Select Slot)"dialog"Select""Close(X)");
            return 
1;
    }
    
CMD:aatt(playerid,params[])
    {
            return 
cmd_o(playerid,params);
    }
    
CMD:aattach(playerid,params[])
    {
            return 
cmd_o(playerid,params);
    }
    
//==============================================================================
    
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
    {
        switch(
dialogid)
        {
            case 
DIALOG_ATTACH_INDEX_SELECTION:
            {
                if(
response)
                {
                    if(
IsPlayerAttachedObjectSlotUsed(playeridlistitem))
                    {
                        
ShowPlayerDialog(playeridDIALOG_ATTACH_EDITREPLACEDIALOG_STYLE_MSGBOX, \
                        
"Player Objects/Attachment: (Delete/Edit)"""COL_WHITE"Do you wish to edit the attachment in that slot, or delete it?""Edit(!)""Delete(X)");
                    }
                    else
                    {
                                            
ShowPlayerDialog(playerid,DIALOG_ATTACH_OBJECT_SELECTION,DIALOG_STYLE_LIST,"Player Objects/Attachment: (Select Object Path)","Path:1 :: "COL_GREY"Server Objects Menu\n"COL_WHITE"Path:2 :: "COL_GREY"Custom Object","Next(>>)","Back(<<)");
                            }
                    
SetPVarInt(playerid"AttachmentIndexSel"listitem);
                }
                return 
1;
            }
            case 
DIALOG_ATTACH_OBJECT_SELECTION:
            {
                if(!
response)
                {
                    
cmd_o(playerid,"");
                }
                if(
response)
                {
                    if(
listitem==0ShowModelSelectionMenuEx(playeridAttachmentObjectsList228+38"Player Objects"DIALOG_ATTACH_MODEL_SELECTION0.00.00.01.00x000000990x000000EE0xACCBF1FF);
                    if(
listitem==1ShowPlayerDialog(playerid,DIALOG_ATTACH_OBJECT2_SELECTION,DIALOG_STYLE_INPUT,"Player Objects/Attachment: (Insert objectid)",""COL_WHITE"Put your custom objectid below, You can also take help from ''http://wiki.sa-mp.com''.","Edit","Back(<<)");
                            }
                    }
            case 
DIALOG_ATTACH_OBJECT2_SELECTION:
            {
                if(!
response)
                {   
ShowPlayerDialog(playerid,DIALOG_ATTACH_OBJECT_SELECTION,DIALOG_STYLE_LIST,"Player Objects/Attachment: (Select Object Path)","Path:1 :: "COL_GREY"Server Objects Menu\n"COL_WHITE"Path:2 :: "COL_GREY"Custom Object","Next(>>)","Back(<<)");    }
                            if(
response)
                            {
                                    if(!
strlen(inputtext))return SendClientMessage(playerid,-1,"PLAYER: You can't leave the coloumn blank."),ShowPlayerDialog(playerid,DIALOG_ATTACH_OBJECT2_SELECTION,DIALOG_STYLE_INPUT,"Player Objects/Attachment: (Insert objectid)",""COL_WHITE"Put your custom objectid below, You can also take help from ''http://wiki.sa-mp.com''.","Edit","Back(<<)");
                                    if(!
IsNumeric(inputtext)) return SendClientMessage(playerid,-1,"PLAYER: You can't fill a object name, only object id's allowed."),ShowPlayerDialog(playerid,DIALOG_ATTACH_OBJECT2_SELECTION,DIALOG_STYLE_INPUT,"Player Objects/Attachment: (Insert objectid)",""COL_WHITE"Put your custom objectid below, You can also take help from ''http://wiki.sa-mp.com''.","Edit","Back(<<)");
                                    new 
obj;
                                if(!
sscanf(inputtext"i"obj))
                                    {
                                            if(
GetPVarInt(playerid"AttachmentUsed") == 1EditAttachedObject(playeridobj);
                                        else
                                        {
                                                
SetPVarInt(playerid"AttachmentModelSel"obj);
                                                new 
string[256+1];
                                                new 
dialog[500];
                                                for(new 
x;x<sizeof(AttachmentBones);x++)
                                                {
                                                    
format(stringsizeof(string), "Bone:%s\n"AttachmentBones[x]);
                                                    
strcat(dialog,string);
                                                }
                                                    
ShowPlayerDialog(playeridDIALOG_ATTACH_BONE_SELECTIONDIALOG_STYLE_LIST, \
                                                    
"{FF0000}Attachment Modification - Bone Selection"dialog"Select""Cancel");
                                        }
                                    }
                            }
            }
            case 
DIALOG_ATTACH_EDITREPLACE:
            {
                if(
responseEditAttachedObject(playeridGetPVarInt(playerid"AttachmentIndexSel"));
                else
                            {
                                
RemovePlayerAttachedObject(playeridGetPVarInt(playerid"AttachmentIndexSel"));
                    new 
file[256];
                                new 
name[24];
                                new 
x=GetPVarInt(playerid"AttachmentIndexSel");
                                new 
f1[15],f2[15],f3[15],f4[15],f5[15],f6[15],f7[15],f8[15],f9[15],f10[15],f11[15];
                                
GetPlayerName(playerid,name,24);
                                
format(file,sizeof(file),"Player Objects/%s.ini",name);
                                if(!
dini_Exists(file)) return 1;
                                
format(f1,15,"O_Model_%d",x);
                                
format(f2,15,"O_Bone_%d",x);
                                    
format(f3,15,"O_OffX_%d",x);
                                
format(f4,15,"O_OffY_%d",x);
                                
format(f5,15,"O_OffZ_%d",x);
                                
format(f6,15,"O_RotX_%d",x);
                                
format(f7,15,"O_RotY_%d",x);
                                
format(f8,15,"O_RotZ_%d",x);
                                
format(f9,15,"O_ScaleX_%d",x);
                                
format(f10,15,"O_ScaleY_%d",x);
                                
format(f11,15,"O_ScaleZ_%d",x);
                                
dini_Unset(file,f1);
                                
dini_Unset(file,f2);
                                
dini_Unset(file,f3);
                                
dini_Unset(file,f4);
                                
dini_Unset(file,f5);
                                
dini_Unset(file,f6);
                                
dini_Unset(file,f7);
                                
dini_Unset(file,f8);
                                
dini_Unset(file,f9);
                                
dini_Unset(file,f10);
                                
dini_Unset(file,f11);
                                    
DeletePVar(playerid"AttachmentIndexSel");
                }
                            return 
1;
            }
            case 
DIALOG_ATTACH_BONE_SELECTION:
            {
                if(
response)
                {
                    
SetPlayerAttachedObject(playeridGetPVarInt(playerid"AttachmentIndexSel"), GetPVarInt(playerid"AttachmentModelSel"), listitem+1);
                    
EditAttachedObject(playeridGetPVarInt(playerid"AttachmentIndexSel"));
                    
SendClientMessage(playerid0xFFFFFFFF"PLAYER: You can also hold SPAWN and use MOUSE to view from either sides.");
                }
                
DeletePVar(playerid"AttachmentIndexSel");
                
DeletePVar(playerid"AttachmentModelSel");
                return 
1;
            }
        }
        return 
0;
    }
    
//==============================================================================
    
public OnPlayerEditAttachedObjectplayeridresponseindexmodelidboneid,
                                       
Float:fOffsetXFloat:fOffsetYFloat:fOffsetZ,
                                       
Float:fRotXFloat:fRotYFloat:fRotZ,
                                       
Float:fScaleXFloat:fScaleYFloat:fScaleZ )
    {
        
/*new debug_string[256+1];
            format(debug_string,256,"SetPlayerAttachedObject(playerid,%d,%d,%d,%f,%f,%f,%f,%f,%f,%f,%f,%f)",
            index,modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ);*/
        
SetPlayerAttachedObject(playerid,index,modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ);
        
SendClientMessage(playerid0xFFFFFFFF"PLAYER: You have finished editing attachments, it has been saved to your database.");
        new 
file[256];
        new 
name[24];
        new 
f1[15],f2[15],f3[15],f4[15],f5[15],f6[15],f7[15],f8[15],f9[15],f10[15],f11[15];
        
GetPlayerName(playerid,name,24);
        
format(file,sizeof(file),"Player Objects/%s.ini",name);
        if(!
dini_Exists(file)) return 1;
        
format(f1,15,"O_Model_%d",index);
        
format(f2,15,"O_Bone_%d",index);
            
format(f3,15,"O_OffX_%d",index);
        
format(f4,15,"O_OffY_%d",index);
        
format(f5,15,"O_OffZ_%d",index);
        
format(f6,15,"O_RotX_%d",index);
        
format(f7,15,"O_RotY_%d",index);
        
format(f8,15,"O_RotZ_%d",index);
        
format(f9,15,"O_ScaleX_%d",index);
        
format(f10,15,"O_ScaleY_%d",index);
        
format(f11,15,"O_ScaleZ_%d",index);
        
dini_IntSet(file,f1,modelid);
        
dini_IntSet(file,f2,boneid);
        
dini_FloatSet(file,f3,fOffsetX);
        
dini_FloatSet(file,f4,fOffsetY);
        
dini_FloatSet(file,f5,fOffsetZ);
        
dini_FloatSet(file,f6,fRotX);
        
dini_FloatSet(file,f7,fRotY);
        
dini_FloatSet(file,f8,fRotZ);
        
dini_FloatSet(file,f9,fScaleX);
        
dini_FloatSet(file,f10,fScaleY);
        
dini_FloatSet(file,f11,fScaleZ);
        return 
1;
    }
    
//==============================================================================
    
public OnPlayerConnect(playerid)
    {
        new 
file[256];
        new 
name[24];
        new 
f1[15],f2[15],f3[15],f4[15],f5[15],f6[15],f7[15],f8[15],f9[15],f10[15],f11[15];
        
GetPlayerName(playerid,name,24);
        
format(file,sizeof(file),"Player Objects/%s.ini",name);
            if(!
dini_Exists(file))
            {
                
dini_Create(file);
                    for(new 
x;x<MAX_OSLOTS;x++)
                    {
                        if(
IsPlayerAttachedObjectSlotUsed(playeridx))
                        {
                                
format(f1,15,"O_Model_%d",x);
                                
format(f2,15,"O_Bone_%d",x);
                                    
format(f3,15,"O_OffX_%d",x);
                                
format(f4,15,"O_OffY_%d",x);
                                
format(f5,15,"O_OffZ_%d",x);
                                
format(f6,15,"O_RotX_%d",x);
                                
format(f7,15,"O_RotY_%d",x);
                                
format(f8,15,"O_RotZ_%d",x);
                                
format(f9,15,"O_ScaleX_%d",x);
                                
format(f10,15,"O_ScaleY_%d",x);
                                
format(f11,15,"O_ScaleZ_%d",x);
                                
dini_IntSet(file,f1,0);
                                
dini_IntSet(file,f2,0);
                                
dini_FloatSet(file,f3,0.0);
                                
dini_FloatSet(file,f4,0.0);
                                
dini_FloatSet(file,f5,0.0);
                                
dini_FloatSet(file,f6,0.0);
                                
dini_FloatSet(file,f7,0.0);
                                
dini_FloatSet(file,f8,0.0);
                                
dini_FloatSet(file,f9,0.0);
                                
dini_FloatSet(file,f10,0.0);
                                
dini_FloatSet(file,f11,0.0);
                            }
                    }
            }
    }
    
//==============================================================================
    
public OnPlayerSpawn(playerid)
    {
        new 
file[256];
        new 
name[24];
        new 
f1[15],f2[15],f3[15],f4[15],f5[15],f6[15],f7[15],f8[15],f9[15],f10[15],f11[15];
        
GetPlayerName(playerid,name,24);
        
format(file,sizeof(file),"Player Objects/%s.ini",name);
        if(!
dini_Exists(file)) return 1;
        for(new 
x;x<MAX_OSLOTS;x++)
            {
                
format(f1,15,"O_Model_%d",x);
                    
format(f2,15,"O_Bone_%d",x);
                    
format(f3,15,"O_OffX_%d",x);
                    
format(f4,15,"O_OffY_%d",x);
                    
format(f5,15,"O_OffZ_%d",x);
                    
format(f6,15,"O_RotX_%d",x);
                    
format(f7,15,"O_RotY_%d",x);
                    
format(f8,15,"O_RotZ_%d",x);
                    
format(f9,15,"O_ScaleX_%d",x);
                    
format(f10,15,"O_ScaleY_%d",x);
                    
format(f11,15,"O_ScaleZ_%d",x);
                if(
dini_Int(file,f1)!=0)
                {
                    
SetPlayerAttachedObject(playerid,x,dini_Int(file,f1),dini_Int(file,f2),dini_Float(file,f3),dini_Float(file,f4),dini_Float(file,f5),dini_Float(file,f6),dini_Float(file,f7),dini_Float(file,f8),dini_Float(file,f9),dini_Float(file,f10),dini_Float(file,f11));
                    }
            }
            return 
1;
    }
    
//==============================================================================
    
public OnPlayerModelSelectionEx(playeridresponseextraidmodelid)
    {
            if(
extraid==DIALOG_ATTACH_MODEL_SELECTION)
            {
                if(!
response)
            {   
ShowPlayerDialog(playerid,DIALOG_ATTACH_OBJECT_SELECTION,DIALOG_STYLE_LIST,"Player Objects/Attachment: (Select Object Path)","Path:1 :: "COL_GREY"Server Objects Menu\n"COL_WHITE"Path:2 :: "COL_GREY"Custom Object","Next(>>)","Back(<<)");    }
                if(
response)
                {
                        if(
GetPVarInt(playerid"AttachmentUsed") == 1EditAttachedObject(playeridmodelid);
                        else
                        {
                                
SetPVarInt(playerid"AttachmentModelSel"modelid);
                    new 
string[256+1];
                                    new 
dialog[500];
                                    for(new 
x;x<sizeof(AttachmentBones);x++)
                            {
                                            
format(stringsizeof(string), "Bone:%s\n"AttachmentBones[x]);
                                            
strcat(dialog,string);
                                    }
                                    
ShowPlayerDialog(playeridDIALOG_ATTACH_BONE_SELECTIONDIALOG_STYLE_LIST, \
                                    
"{FF0000}Attachment Modification - Bone Selection"dialog"Select""Cancel");
                        }
//else DeletePVar(playerid, "AttachmentIndexSel");
                    
}
            }
            return 
1;
    }
    
//==============================================================================
    
stock IsNumeric(string[])
    {
            for (new 
0strlen(string); ji++)
            {
                    if (
string[i] > '9' || string[i] < '0') return 0;
            }
            return 
1;
    }
    
//============================================================================== 
Reply
#2

I saw that you use Zombie server which doesn't have attachment system.
You can use this filterscript. > https://sampforum.blast.hk/showthread.php?tid=209234
Reply
#3

Quote:
Originally Posted by Clad
Посмотреть сообщение
I saw that you use Zombie server which doesn't have attachment system.
You can use this filterscript. > https://sampforum.blast.hk/showthread.php?tid=209234
Will this save the objects so that players won't have to reattach there objects when they re-enter the server?
Reply


Forum Jump:


Users browsing this thread: