Please help
#1

PHP код:
CMD:editobject(playeridparams[])
{
 new 
objectid;
 if(
sscanf(params"d"objectid))
 {
     
SendClientMessage(playerid, -1"[USAGE]/editobject (objid)");
     return 
1;
 }
 
EditDynamicObject(playeridobjectid);
 return 
1;
}
public 
OnPlayerEditObject(playeridplayerobjectobjectidresponseFloat:fXFloat:fYFloat:fZFloat:fRotXFloat:fRotYFloat:fRotZ)
{
 new 
Float:oldXFloat:oldYFloat:oldZFloat:oldRotXFloat:oldRotYFloat:oldRotZQuery[800];
 
GetObjectPos(objectidoldXoldYoldZ);
 
GetObjectRot(objectidoldRotXoldRotYoldRotZ);
 if(!
playerobject)
 {
     if(!
IsValidObject(objectid)) return 1;
     
SetObjectPos(objectidfXfYfZ);
      
SetObjectRot(objectidfRotXfRotYfRotZ);
 }
 if(
response == EDIT_RESPONSE_UPDATE)
 {
     
GetObjectPos(objectidfXfYfZ);
     
GetObjectRot(objectidfRotXfRotYfRotZ);
  
format(Querysizeof(Query), "UPDATE loot SET objx = %f, objy = %f, objz = %f, objrx = %f, objry = %f, objrz = %f WHERE objid = %d",
  
fXfYfZfRotXfRotYfRotZobjectid);
  
db_query(LootQuery);
  print(
Query);
 }
 if(
response == EDIT_RESPONSE_FINAL)
 {
  
GetObjectPos(objectidfXfYfZ);
  
GetObjectRot(objectidfRotXfRotYfRotZ);
  
format(Querysizeof(Query), "UPDATE loot SET objx = %f, objy = %f, objz = %f, objrx = %f, objry = %f, objrz = %f WHERE objid = %d",
  
fXfYfZfRotXfRotYfRotZobjectid);
  
db_query(LootQuery);
  print(
Query);
 }
 if(
response == EDIT_RESPONSE_CANCEL)
 {
  if(!
playerobject)
  {
   
SetObjectPos(objectidoldXoldYoldZ);
   
SetObjectRot(objectidoldRotXoldRotYoldRotZ);
  }
  else
  {
   
SetPlayerObjectPos(playeridobjectidoldXoldYoldZ);
   
SetPlayerObjectRot(playeridobjectidoldRotXoldRotYoldRotZ);
  }
 }
 return 
1;

When I type /editobject ingame it edits the right object without any problem but it sends the wrong objectid to the database, it always send ID: 2, I don't have any idea why that would happen and why ID 2?

PHP код:
 if(response == EDIT_RESPONSE_FINAL)
 {
  
GetObjectPos(objectidfXfYfZ);
  
GetObjectRot(objectidfRotXfRotYfRotZ);
  
format(Querysizeof(Query), "UPDATE loot SET objx = %f, objy = %f, objz = %f, objrx = %f, objry = %f, objrz = %f WHERE objid = %d",
  
fXfYfZfRotXfRotYfRotZobjectid);
  
db_query(LootQuery);
  print(
Query);
 } 
It sends ID: 2 here, I checked it from printing it but as I said it edits/selects the right id ingame. Anyone know why this would happen with me?

Thanks
Reply
#2

Anyone?
Reply
#3

You're confusing ObjectID with ModelID?

That'd be why the ID comes out as 2.
Reply
#4

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
You're confusing ObjectID with ModelID?

That'd be why the ID comes out as 2.
No sir, I tried it on many objects model ids. it updates them all as ID 2 but in game when I write /editobject id, it selects the right id, when I click on the save button, it sends the information correct but the object id wrong, it sends ID 2 all the time SO it updates object id 2 in the database only.

I really need a help here, thanks.
Reply
#5

You're mixing up ModelID with ObjectID...

ObjectID is the ID the server gives the object so that it can be found and tracked by the script easier.


That is what you are ending up returning, not what you think it is...



To highlight this more, save the object, and create the next...



I'll bet you, it now saves "3".
Reply
#6

Dynamic objects are player objects. If you use the Streamer you must also use the Streamer callbacks.
Reply
#7

You are using regular object functions and the regular object callback. But in the command you are using EditDynamicObject. So, are you using streamer or not?

EDIT: Vince beat me, that's what happens when I have 10 tabs open and check them one at a time...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)