I've been working on updating my Infinite Ammo Plugin, and have been working with sdktools a bit.
I was wondering which of these would be better as far as optimization.
Example 1(SDKCall):
Code:
new Handle:hGiveAmmo = INVALID_HANDLE;
public OnPluginStart()
{
new Handle:hFile = LoadGameConfigFile("gamedatafile");
if(hFile == INVALID_HANDLE) SetFailState("Gamedata file not found: gamedatafile");
StartPrepSDKCall(SDKCall_Player);
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
PrepSDKCall_AddParameter(SDKType_Bool, SDKPass_Plain);
PrepSDKCall_SetFromConf(hFile, SDKConf_Virtual, "GiveAmmo");
hGiveAmmo = EndPrepSDKCall();
CloseHandle(hFile);
}
SDKGiveAmmo(client, iAmmo, iWeaponSlot, bool:bDisableSound)
{
SDKCall(hGiveAmmo, client, iAmmo, iWeaponSlot+1, bDisableSound);
}
Example 2(Datamaps/Netprops):
Code:
new iOffset_Ammo;
public OnPluginStart()
{
iOffset_Ammo = FindSendPropInfo("CTFPlayer", "m_iAmmo");
}
SetAmmo(client, iWeapon, iAmmo)
{
new iAmmoType = GetEntProp(iWeapon, Prop_Send, "m_iPrimaryAmmoType")*4;
SetEntData(client, iAmmoType+iOffset_Ammo, iAmmo, 4, true);
}
I'm guessing the prop version would be slower due to getting ammotype every time, however I don't know how computationally expensive sdkcalls are.
Also, what if I specified ammotype myself, leaving only the SetEntData?