Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
fix weapon name is nullptr crash bug
Browse files Browse the repository at this point in the history
  • Loading branch information
huoji120 committed Oct 19, 2023
1 parent e5f2541 commit e5bb3ec
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions csgo2/script_apis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,14 @@ auto luaApi_GivePlayerWeapon(lua_State* luaVm) -> int {
const auto playerIndex = lua_tointeger(luaVm, 1);
const auto weaponName = lua_tostring(luaVm, 2);
auto isSuccess = false;
ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) {
if (playerController->m_bPawnIsAlive() == false) {
return;
}
isSuccess =
GameWeapons::ParseWeaponCommand(playerController, weaponName);
});
if (weaponName != nullptr) {
ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) {
if (playerController->m_bPawnIsAlive() == false) {
return;
}
isSuccess = GameWeapons::ParseWeaponCommand(playerController, weaponName);
});
}
lua_pop(luaVm, 2);
lua_pushboolean(luaVm, isSuccess);
return 1;
Expand Down

0 comments on commit e5bb3ec

Please sign in to comment.