Returing function
#1

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
Reply
#2

Quote:
Originally Posted by Steve M.
View Post
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.
Reply
#3

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?
Reply
#4

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);
Reply
#5

Thanks, Nero_3D. I forgot to remove the re-tag.

Quote:
Originally Posted by Nero_3D
View Post
Altought the code looks pretty string, why do you save the data and create the vehicle additionally ?
I'm just playing around.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)