31.01.2014, 01:47
I've the New Toy Editing System 0.3e working fine ,but when i detach the toy and re-attach it again it sets to the old position which i didnt edit ,i hope you guys can help me with it
++ REP
pawn Код:
#define LISTTOYS_DELETETOY 4534
#define LISTTOYS_DELETETOYCONFIRM 4535
#define EDIT_RESPONSE_FINAL 1
#define SHOPOBJECT_GIVEPLAYER 3231
#define SHOPOBJECT_SUCCESS 3234
#define TOYS 10131
#define DELETETOY 10132
#define WEARTOY 10133
#define BUYTOYS 10134
#define BUYTOYS2 10135
#define BUYTOYS3 10136
#define BUYTOYSGOLD 10137
#define BUYTOYSGOLD2 10138
#define BUYTOYSGOLD3 10139
#define EDITTOYS 10140
#define EDITTOYS2 10141
#define EDITTOYSBONE 10142
#define EDITTOYSPX 10143
#define EDITTOYSPY 10144
#define EDITTOYSPZ 10145
#define EDITTOYSRX 10146
#define EDITTOYSRY 10147
#define EDITTOYSRZ 10148
#define EDITTOYSSX 18493
#define EDITTOYSSY 18494
#define EDITTOYSSZ 18495
#define BUYTOYSPLAT 11148
#define BUYTOYSPLAT2 11149
#define BUYTOYSPLAT3 11150
pawn Код:
stock ShowEditMenu(playerid)
{
new
iIndex = GetPVarInt(playerid, "ToySlot");
if(IsPlayerAttachedObjectSlotUsed(playerid, iIndex))
{
RemovePlayerAttachedObject(playerid, iIndex);
}
if(PlayerToyInfo[playerid][iIndex][ptScaleX] == 0) {
PlayerToyInfo[playerid][iIndex][ptScaleX] = 1.0;
PlayerToyInfo[playerid][iIndex][ptScaleY] = 1.0;
PlayerToyInfo[playerid][iIndex][ptScaleZ] = 1.0;
}
SetPlayerAttachedObject(playerid, iIndex, PlayerToyInfo[playerid][iIndex][ptModelID],
PlayerToyInfo[playerid][iIndex][ptBone], PlayerToyInfo[playerid][iIndex][ptPosX],
PlayerToyInfo[playerid][iIndex][ptPosY], PlayerToyInfo[playerid][iIndex][ptPosZ],
PlayerToyInfo[playerid][iIndex][ptRotX], PlayerToyInfo[playerid][iIndex][ptRotY],
PlayerToyInfo[playerid][iIndex][ptRotZ], PlayerToyInfo[playerid][iIndex][ptScaleX],
PlayerToyInfo[playerid][iIndex][ptScaleY], PlayerToyInfo[playerid][iIndex][ptScaleZ]);
new stringg[128];
format(stringg, sizeof(stringg), "Bone (%s)\nEdit Toy", HoldingBones[PlayerToyInfo[playerid][iIndex][ptBone]]);
ShowPlayerDialog(playerid, EDITTOYS2, DIALOG_STYLE_LIST, "Toy Menu: Edit", stringg, "Select", "Cancel");
}
pawn Код:
if((dialogid == TOYS) && response)
{
if(listitem == 0)
{
new stringg[512];
for(new x;x<MAX_PLAYERTOYS;x++)
{
new name[24];
format(name, sizeof(name), "None");
for(new i;i<sizeof(HoldingObjectsAll);i++)
{
if(HoldingObjectsAll[i][holdingmodelid] == PlayerToyInfo[playerid][x][ptModelID])
{
format(name, sizeof(name), "%s", HoldingObjectsAll[i][holdingmodelname]);
}
}
for(new i;i<sizeof(HoldingObjectsPlat);i++)
{
if(HoldingObjectsPlat[i][holdingmodelid] == PlayerToyInfo[playerid][x][ptModelID])
{
format(name, sizeof(name), "%s", HoldingObjectsPlat[i][holdingmodelname]);
}
}
format(stringg, sizeof(stringg), "%s(%d) %s (Bone: %s)\n", stringg, x, name, HoldingBones[PlayerToyInfo[playerid][x][ptBone]]);
}
ShowPlayerDialog(playerid, WEARTOY, DIALOG_STYLE_LIST, "Select a Toy", stringg, "Select", "Cancel");
}
else if(listitem == 1)
{
new stringg[512];
for(new x;x<MAX_PLAYERTOYS;x++)
{
new name[24];
format(name, sizeof(name), "None");
for(new i;i<sizeof(HoldingObjectsAll);i++)
{
if(HoldingObjectsAll[i][holdingmodelid] == PlayerToyInfo[playerid][x][ptModelID])
{
format(name, sizeof(name), "%s", HoldingObjectsAll[i][holdingmodelname]);
}
}
for(new i;i<sizeof(HoldingObjectsPlat);i++)
{
if(HoldingObjectsPlat[i][holdingmodelid] == PlayerToyInfo[playerid][x][ptModelID])
{
format(name, sizeof(name), "%s", HoldingObjectsPlat[i][holdingmodelname]);
}
}
format(stringg, sizeof(stringg), "%s(%d) %s (Bone: %s)\n", stringg, x, name, HoldingBones[PlayerToyInfo[playerid][x][ptBone]]);
}
ShowPlayerDialog(playerid, EDITTOYS, DIALOG_STYLE_LIST, "Select a Toy", stringg, "Select", "Cancel");
}
else if(listitem == 2)
{
new stringg[512];
for(new x;x<MAX_PLAYERTOYS;x++)
{
new name[24];
format(name, sizeof(name), "None");
for(new i;i<sizeof(HoldingObjectsAll);i++)
{
if(HoldingObjectsAll[i][holdingmodelid] == PlayerToyInfo[playerid][x][ptModelID])
{
format(name, sizeof(name), "%s", HoldingObjectsAll[i][holdingmodelname]);
}
}
for(new i;i<sizeof(HoldingObjectsPlat);i++)
{
if(HoldingObjectsPlat[i][holdingmodelid] == PlayerToyInfo[playerid][x][ptModelID])
{
format(name, sizeof(name), "%s", HoldingObjectsPlat[i][holdingmodelname]);
}
}
format(stringg, sizeof(stringg), "%s(%d) %s (Bone: %s)\n", stringg, x, name, HoldingBones[PlayerToyInfo[playerid][x][ptBone]]);
}
ShowPlayerDialog(playerid, DELETETOY, DIALOG_STYLE_LIST, "Select a Toy", stringg, "Delete", "Cancel");
}
}
if((dialogid == EDITTOYS) && response)
{
if(PlayerToyInfo[playerid][listitem][ptModelID] == 0)
{
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Toy Menu: Edit", "Woops! You don't have anything on that slot", "OK", "");
}
else
{
SendClientMessageEx(playerid, COLOR_WHITE, "{AA3333}HINT:{FFFF00} Position your camera differently to better see where your editing.");
SetPVarInt(playerid, "ToySlot", listitem);
ShowEditMenu(playerid);
}
}
if((dialogid == EDITTOYS2)) {
if(response) switch(listitem) {
case 0: ShowPlayerDialog(playerid, EDITTOYSBONE, DIALOG_STYLE_LIST, "Select a Bone", "Spine\nHead\nLeft upper arm\nRight upper arm\nLeft hand\nRight hand\nLeft thigh\nRight thigh\nLeft foot\nRight foot\nRight calf\nLeft calf\nLeft forearm\nRight forearm\nLeft clavicle\nRight clavicle\nNeck\nJaw", "Select", "Cancel");
case 1:
{
SendClientMessage(playerid, COLOR_WHITE, "HINT: Hold {8000FF}~k~~PED_SPRINT~ {FFFFAA}to move your camera, press escape to cancel");
EditAttachedObject(playerid, GetPVarInt(playerid, "ToySlot"));
}
}
else
{
new stringg[512];
for(new x;x<MAX_PLAYERTOYS;x++)
{
new name[24];
format(name, sizeof(name), "None");
for(new i;i<sizeof(HoldingObjectsAll);i++)
{
if(HoldingObjectsAll[i][holdingmodelid] == PlayerToyInfo[playerid][x][ptModelID])
{
format(name, sizeof(name), "%s", HoldingObjectsAll[i][holdingmodelname]);
break;
}
}
if(PlayerToyInfo[playerid][x][ptModelID] != 0 && (strcmp(name, "Obj ID: %d", true) == 0))
{
format(name, sizeof(name), "Obj ID: %d", PlayerToyInfo[playerid][x][ptModelID]);
}
format(stringg, sizeof(stringg), "%s(%d) %s (Bone: %s)\n", stringg, x, name, HoldingBones[PlayerToyInfo[playerid][x][ptBone]]);
}
ShowPlayerDialog(playerid, EDITTOYS, DIALOG_STYLE_LIST, "Select a Toy", stringg, "Select", "Cancel");
}
}
if(dialogid == EDITTOYSBONE)
{
if(response)
{
PlayerToyInfo[playerid][GetPVarInt(playerid, "ToySlot")][ptBone] = listitem+1;
}
ShowEditMenu(playerid);
}
if((dialogid == WEARTOY) && response)
{
if(PlayerToyInfo[playerid][listitem][ptModelID] == 0)
{
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Toy Menu: Attach/Deattach", "Woops! You don't have anything to put on from that slot.", "OK", "");
}
else
{
if(IsPlayerAttachedObjectSlotUsed(playerid, listitem))
{
new name[24];
format(name, sizeof(name), "None");
for(new i;i<sizeof(HoldingObjectsAll);i++)
{
if(HoldingObjectsAll[i][holdingmodelid] == PlayerToyInfo[playerid][listitem][ptModelID])
{
format(name, sizeof(name), "%s", HoldingObjectsAll[i][holdingmodelname]);
break;
}
}
if(PlayerToyInfo[playerid][listitem][ptModelID] != 0 && (strcmp(name, "None", true) == 0))
{
format(name, sizeof(name), "Obj ID: %d", PlayerToyInfo[playerid][listitem][ptModelID]);
}
format(string, sizeof(string), "Successfully dettached %s (Bone: %s) (Slot: %d)", name, HoldingBones[PlayerToyInfo[playerid][listitem][ptBone]], listitem);
SendClientMessageEx(playerid, COLOR_RED, string);
RemovePlayerAttachedObject(playerid, listitem);
}
else
{
if(PlayerToyInfo[playerid][listitem][ptScaleX] == 0) {
PlayerToyInfo[playerid][listitem][ptScaleX] = 1.0;
PlayerToyInfo[playerid][listitem][ptScaleY] = 1.0;
PlayerToyInfo[playerid][listitem][ptScaleZ] = 1.0;
}
SetPlayerAttachedObject(playerid, listitem, PlayerToyInfo[playerid][listitem][ptModelID], PlayerToyInfo[playerid][listitem][ptBone], PlayerToyInfo[playerid][listitem][ptPosX], PlayerToyInfo[playerid][listitem][ptPosY], PlayerToyInfo[playerid][listitem][ptPosZ],
PlayerToyInfo[playerid][listitem][ptRotX], PlayerToyInfo[playerid][listitem][ptRotY], PlayerToyInfo[playerid][listitem][ptRotZ], PlayerToyInfo[playerid][listitem][ptScaleX], PlayerToyInfo[playerid][listitem][ptScaleY], PlayerToyInfo[playerid][listitem][ptScaleZ]);
new name[24];
format(name, sizeof(name), "None");
for(new i;i<sizeof(HoldingObjectsAll);i++)
{
if(HoldingObjectsAll[i][holdingmodelid] == PlayerToyInfo[playerid][listitem][ptModelID])
{
format(name, sizeof(name), "%s", HoldingObjectsAll[i][holdingmodelname]);
break;
}
}
if(PlayerToyInfo[playerid][listitem][ptModelID] != 0 && (strcmp(name, "None", true) == 0))
{
format(name, sizeof(name), "Obj ID: %d", PlayerToyInfo[playerid][listitem][ptModelID]);
}
format(string, sizeof(string), "Successfully attached %s (Bone: %s) (Slot: %d)", name, HoldingBones[PlayerToyInfo[playerid][listitem][ptBone]], listitem);
SendClientMessageEx(playerid, COLOR_RED, string);
}
}
}
if((dialogid == DELETETOY) && response)
{
PlayerToyInfo[playerid][listitem][ptModelID] = 0;
PlayerToyInfo[playerid][listitem][ptBone] = 0;
PlayerToyInfo[playerid][listitem][ptPosX] = 0.0;
PlayerToyInfo[playerid][listitem][ptPosY] = 0.0;
PlayerToyInfo[playerid][listitem][ptPosZ] = 0.0;
PlayerToyInfo[playerid][listitem][ptPosX] = 0.0;
PlayerToyInfo[playerid][listitem][ptPosY] = 0.0;
PlayerToyInfo[playerid][listitem][ptPosZ] = 0.0;
if(IsPlayerAttachedObjectSlotUsed(playerid, listitem))
{
RemovePlayerAttachedObject(playerid, listitem);
}
format(string, sizeof(string), "You have deleted your toy in slot %d", listitem);
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Toy Menu", string, "OK", "");
}
else if(dialogid == LISTTOYS_DELETETOY)
{
if(response)
{
if(PlayerInfo[playerid][pAdmin] < 4)
{
return SendClientMessageEx(playerid, COLOR_GRAD2, "You're not authorized to do that");
}
new giveplayerid = GetPVarInt(playerid, "listitem_giveplayerid");
SetPVarInt(playerid, "listitem_toyslot", listitem);
format(string, sizeof(string), "Are you sure you want to delete %s's toy (Model ID: %d) from slot %d?", GetPlayerNameEx(giveplayerid), PlayerToyInfo[giveplayerid][listitem][ptModelID], listitem);
ShowPlayerDialog(playerid, LISTTOYS_DELETETOYCONFIRM, DIALOG_STYLE_MSGBOX, "Delete Toy - Are you sure?", string, "Yes", "No");
}
}
else if(dialogid == LISTTOYS_DELETETOYCONFIRM)
{
if(response)
{
new stringg[128], giveplayerid = GetPVarInt(playerid, "listitem_giveplayerid"), slot = GetPVarInt(playerid, "listitem_toyslot");
new object = PlayerToyInfo[giveplayerid][slot][ptModelID];
if(!IsPlayerConnected(giveplayerid) || giveplayerid == INVALID_PLAYER_ID)
{
ShowPlayerDialog(playerid, SHOPOBJECT_GIVEPLAYER, DIALOG_STYLE_MSGBOX, "Delete Toy - Player ID", "ERROR: That player is not connected", "OK", "");
return 1;
}
format(stringg, sizeof(stringg), "You have deleted %s's object %d in slot %d", GetPlayerNameEx(giveplayerid), object, slot);
ShowPlayerDialog(playerid, SHOPOBJECT_SUCCESS, DIALOG_STYLE_MSGBOX, "Delete Toy - Success", stringg, "OK", "");
format(stringg, sizeof(stringg), "Admin %s has deleted your toy (obj model: %d) from slot %d.", GetPlayerNameEx(playerid), object, slot);
SendClientMessageEx(giveplayerid, COLOR_WHITE, stringg);
format(string, sizeof(string), "[TOYDELETE] %s deleted %s's object %d in slot %d", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), object, slot);
PlayerToyInfo[giveplayerid][slot][ptModelID] = 0;
PlayerToyInfo[giveplayerid][slot][ptBone] = 0;
Log("logs/toydelete.log", string);
}
}