MoveDynamicObject (Function passes incorrect Value) -
BKarner - 19.07.2015
I have two functions, when I pass through "1" into a function, when it comes out to the other side it comes out as "0" no matter what number I pass it originally.
I've debugged both sides and it's always correct outside of the function and incorrect on the inside.
Код:
stock MoveMoveableObject(obj[], obj_size){
new MoveableObject[Class_MoveableObject];
Utils_ArrayEqualsArray(MoveableObject, obj, sizeof(MoveableObject), obj_size);
if(MoveableObject[bCanBeMoved] == true){
new ObjectID = MoveableObject[objectID];
if(MoveableObject[bIsInStartState] == true){
MoveDynamicObjectEx(ObjectID, MoveableObject[endLocation], MoveableObject[endRotation], 3.0);
MoveableObject[bIsInStartState] = false;
new debugString[128];
format(debugString, sizeof(debugString), "ObjectID: %d", ObjectID);
SendClientMessageToAll(0xFFFFFF, debugString);
} else {
MoveDynamicObjectEx(ObjectID, MoveableObject[startLocation], MoveableObject[startRotation], 3.0);
MoveableObject[bIsInStartState] = true;
}
Utils_ArrayEqualsArray(obj, MoveableObject, sizeof(MoveableObject), obj_size);
} else {
return;
}
}
Код:
stock MoveDynamicObjectEx(objectID, loc_vec[], rot_vec[], speed){
new debugString[128];
format(debugString, sizeof(debugString), "ObjectID: %d || LocX: %f || LocY: %f || LocZ: %f || Speed: %f ((IsMoving: %b))", objectID, loc_vec[x], loc_vec[y], loc_vec[z], speed, IsObjectMoving(objectID));
SendClientMessageToAll(0xFFFFFF, debugString);
MoveDynamicObject(2, loc_vec[x], loc_vec[y], loc_vec[z], speed, rot_vec[x], rot_vec[y], rot_vec[z]);
}
The bug is in the "MoveDynamicObjectEx" function and the variable is "objectID". No matter what number I pass it, it's value is always 0 inside the function.
Re: MoveDynamicObject (Function passes incorrect Value) -
BKarner - 26.07.2015
Bump. I've been trying to debug this and there's no reason in my script why it should be changing, any idea of a work around?
Re: MoveDynamicObject (Function passes incorrect Value) -
Firewire - 26.07.2015
Call it through a function instead.
pawn Код:
forward MoveDynamicObjectEx(objectID, loc_vec[], rot_vec[], speed);
public MoveDynamicObjectEx(objectID, loc_vec[], rot_vec[], speed)
{
new debugString[128];
format(debugString, sizeof(debugString), "ObjectID: %d || LocX: %f || LocY: %f || LocZ: %f || Speed: %f ((IsMoving: %b))", objectID, loc_vec[x], loc_vec[y], loc_vec[z], speed, IsObjectMoving(objectID));
SendClientMessageToAll(0xFFFFFF, debugString);
MoveDynamicObject(2, loc_vec[x], loc_vec[y], loc_vec[z], speed, rot_vec[x], rot_vec[y], rot_vec[z]);
return true;
}
Re: MoveDynamicObject (Function passes incorrect Value) -
BKarner - 26.07.2015
Thanks!, this has fixed the issue completely.