Returing function - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Returing function (
/showthread.php?tid=278358)
Returing function -
Steve M. - 21.08.2011
Hey guys. I have made this hook for AddStaticVehicleEx and I want to ask you can I return function?
Here is my hook:
pawn Code:
stock _GG_AddStaticVehicleEx(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:angle, color1, color2, respawn_delay)
{
vehCreated++;
VehicleInfo[vehCreated][vModel] = modelid;
VehicleInfo[vehCreated][vPos][0] = spawn_x;
VehicleInfo[vehCreated][vPos][1] = spawn_y;
VehicleInfo[vehCreated][vPos][2] = spawn_z;
VehicleInfo[vehCreated][vRot] = angle;
VehicleInfo[vehCreated][vCol][0] = color1;
VehicleInfo[vehCreated][vCol][1] = color2;
VehicleInfo[vehCreated][vLocked] = 0;
VehicleInfo[vehCreated][vOwned] = 0;
strmid(VehicleInfo[vehCreated][vOwner], " ", 0, 0, 20);
return AddStaticVehicleEx(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:angle, color1, color2, respawn_delay);
}
#if defined _ALS_AddStaticVehicleEx
#undef AddStaticVehicleEx
#else
#define _ALS_AddStaticVehicleEx
#endif
#define AddStaticVehicleEx _GG_AddStaticVehicleEx
Re: Returing function -
Improvement™ - 21.08.2011
Quote:
Originally Posted by Steve M.
Hey guys. I have made this hook for AddStaticVehicleEx and I want to ask you can I return function?
|
What do you exactly mean by "returning function", as in that it will be called twice? or as in just like a loop that keeps making loops continuesly? An exact definition would be great for most of the readers to understand.
Re: Returing function -
Steve M. - 21.08.2011
See my hook function:
pawn Code:
return AddStaticVehicleEx(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:angle, color1, color2, respawn_delay);
That's what I mean by returning a function. When _GG_AddStaticVehicleEx is called it should return AddStaticVehicleEx. And that's my question, is that possible?
AW: Returing function -
Nero_3D - 21.08.2011
sure but you should check if
vehCreated doesn't go over the array size of
VehicleInfo
Altought the code looks pretty string, why do you save the data and create the vehicle additionally ?
And you dont need to retag the variables
pawn Code:
return AddStaticVehicleEx(modelid, spawn_x, spawn_y, spawn_z, angle, color1, color2, respawn_delay);
Re: AW: Returing function -
Steve M. - 21.08.2011
Thanks, Nero_3D. I forgot to remove the re-tag.
Quote:
Originally Posted by Nero_3D
Altought the code looks pretty string, why do you save the data and create the vehicle additionally ?
|
I'm just playing around.