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
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);
}
}
and it doesnt show to other players that its edited ,it shows as it first position without editing
You could better use EditAttachedObject function, to edit attached items and do all your saving under OnPlayerEditAttachedObject
but i'm still having the same problem.