Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-------------------------------------------------
- //
- // This is an example of using the EditAttachedObject functions
- // to allow the player to customize their character.
- //
- // h02 2012
- //
- // SA-MP 0.3e and above
- //
- //-------------------------------------------------
- #include <a_samp>
- #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
- enum AttachmentEnum
- {
- attachmodel,
- attachname[24]
- }
- new AttachmentObjects[][AttachmentEnum] = {
- {ID objekta, "Text"},
- {ID objekta, "Text"},
- {ID objekta, "Text"}
- };
- new AttachmentBones[][24] = {
- {"Kicma"},
- {"Glava"},
- {"Leva Nadlaktica"},
- {"Desna Nadlaktica"},
- {"Leva Ruka"},
- {"Desna Ruka"},
- {"Leva Butina"},
- {"Desna Butina"},
- {"Leva Noga"},
- {"Desna Noga"},
- {"Desna Noga List"},
- {"Leva Noga List"},
- {"Leva Podlaktica"},
- {"Desna Podlaktica"},
- {"Levo Rame"},
- {"Desno Rame"},
- {"Vrat"},
- {"Vilica"}
- };
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp(cmdtext, "/create", true))
- {
- new string[128];
- for(new x;x<MAX_PLAYER_ATTACHED_OBJECTS;x++)
- {
- if(IsPlayerAttachedObjectSlotUsed(playerid, x)) format(string, sizeof(string), "%s%d (Used)\n", string, x);
- else format(string, sizeof(string), "%s%d\n", string, x);
- }
- ShowPlayerDialog(playerid, DIALOG_ATTACH_INDEX_SELECTION, DIALOG_STYLE_LIST, \
- "{FF0000}Attachment Modification - Index Selection", string, "Select", "Cancel");
- return 1;
- }
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case DIALOG_ATTACH_INDEX_SELECTION:
- {
- if(response)
- {
- if(IsPlayerAttachedObjectSlotUsed(playerid, listitem))
- {
- ShowPlayerDialog(playerid, DIALOG_ATTACH_EDITREPLACE, DIALOG_STYLE_MSGBOX, \
- "{FF0000}Attachment Modification", "Do you wish to edit the attachment in that slot, or delete it?", "Edit", "Delete");
- }
- else
- {
- new string[4000+1];
- for(new x;x<sizeof(AttachmentObjects);x++)
- {
- format(string, sizeof(string), "%s%s\n", string, AttachmentObjects[x][attachname]);
- }
- ShowPlayerDialog(playerid, DIALOG_ATTACH_MODEL_SELECTION, DIALOG_STYLE_LIST, \
- "{FF0000}Attachment Modification - Model Selection", string, "Select", "Cancel");
- }
- SetPVarInt(playerid, "AttachmentIndexSel", listitem);
- }
- return 1;
- }
- case DIALOG_ATTACH_EDITREPLACE:
- {
- if(response) EditAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"));
- else RemovePlayerAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"));
- DeletePVar(playerid, "AttachmentIndexSel");
- return 1;
- }
- case DIALOG_ATTACH_MODEL_SELECTION:
- {
- if(response)
- {
- if(GetPVarInt(playerid, "AttachmentUsed") == 1) EditAttachedObject(playerid, listitem);
- else
- {
- SetPVarInt(playerid, "AttachmentModelSel", AttachmentObjects[listitem][attachmodel]);
- new string[256+1];
- for(new x;x<sizeof(AttachmentBones);x++)
- {
- format(string, sizeof(string), "%s%s\n", string, AttachmentBones[x]);
- }
- ShowPlayerDialog(playerid, DIALOG_ATTACH_BONE_SELECTION, DIALOG_STYLE_LIST, \
- "{FF0000}Attachment Modification - Bone Selection", string, "Select", "Cancel");
- }
- }
- else DeletePVar(playerid, "AttachmentIndexSel");
- return 1;
- }
- case DIALOG_ATTACH_BONE_SELECTION:
- {
- if(response)
- {
- SetPlayerAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"), GetPVarInt(playerid, "AttachmentModelSel"), listitem+1);
- EditAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"));
- SendClientMessage(playerid, 0xFFFFFFFF, "Hint: Use {FFFF00}~k~~PED_SPRINT~{FFFFFF} to look around.");
- }
- DeletePVar(playerid, "AttachmentIndexSel");
- DeletePVar(playerid, "AttachmentModelSel");
- return 1;
- }
- }
- return 0;
- }
- public OnPlayerEditAttachedObject( playerid, response, index, modelid, boneid,
- Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ,
- Float:fRotX, Float:fRotY, Float:fRotZ,
- Float:fScaleX, Float:fScaleY, Float: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);
- print(debug_string);
- //SendClientMessage(playerid, 0xFFFFFFFF, debug_string);
- SetPlayerAttachedObject(playerid,index,modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ);
- SendClientMessage(playerid, 0xFFFFFFFF, "You finished editing an attached object");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment