oscar-broman / samp-weapon-config

A more consistent and responsive damage system with many new features
Apache License 2.0
93 stars 84 forks source link

stock IsPlayerSpawned crash, changed to Public works #64

Closed rt-2 closed 7 years ago

rt-2 commented 7 years ago

I got "runtime error 11: devided by zero" in OnPlayerWeaponShot, unless I change the IsPlayerSpawned stock function into a forwarded public function.

Now everything works fine,, weird. Thought I'd let you guys know...

Thank you, rt-2

oscar-broman commented 7 years ago

Remove your IsPlayerSpawned - weapon-config will make its own.

rt-2 commented 7 years ago

I am talking about the 'IsPlayerSpawned' inside weapon-config that I need to modify. I don't think I ever use this function myself, I use 'IsPlayerValid' or I have a variable 'PlayerSpawned' that goes from -3 to 1. So I don't use this function name myself.

oscar-broman commented 7 years ago

Then it is most definitely a compiler bug - do you have those error messages in your log? I need to see where it is triggered.

rt-2 commented 7 years ago

It's triggered from OnPlayerGiveDamage in

if (!IsPlayerSpawned(playerid)) {
    // Make sure the rejected hit wasn't added in OnPlayerWeaponShot
    if (!IsBulletWeapon(weaponid) || s_LastShot[playerid][e_Valid]) {
        AddRejectedHit(playerid, damagedid, HIT_NOT_SPAWNED, weaponid);
    }
    return 0;
}

AddRejectedHit is not called and the error is returned if IsPlayerSpawned is a stock

oscar-broman commented 7 years ago

I think another include or perhaps your gamemode declares a IsPlayerSpawned. It could be that it is declared as static, which should not cause problems but I have encountered problems with the Pawn compiler before where a static function sharing the name of a global function caused strange behavior.

Could you search through your project for IsPlayerSpawned?

rt-2 commented 7 years ago

It's a native in YSF.

rt-2 commented 7 years ago

I didn't mean to 'close' this issue, I pressed the wrong button

oscar-broman commented 7 years ago

The one in YSF will not be correct and should not be used. I'd suggest doing something like this:

#define IsPlayerSpawned IsPlayerSpawned_YSF
#include <YSF>
#undef IsPlayerSpawned
#include <weapon-config>
rt-2 commented 7 years ago

So the one in weapon-config willl be compatible with YSF AND weapon-config? I just don't wanna break my YSF either.

Thank you,

oscar-broman commented 7 years ago

Yes it will be. The one in YSF is very simple - it just checks the player state and whether spawn info has been given. weapon-config does that also.

https://github.com/kurta999/YSF/blob/94baaf7b946ddf0a34820b2d4ac734774ecb116f/src/Natives.cpp#L2141