If a player has a weapon in his inventory, then what exactly do you want to do?
the moment a player dies and the victim had more then one weapon (knife + any other PRIMARY weapon) then i want to ignore the rest of the following code.
Spoiler
its just an example:
PHP Code:
new Weapons[32]; new numWeapons, i, weapon; get_user_weapons(iVictim,Weapons, numWeapons); for (i=0; i<numWeapons; i++) { weapon = Weapons[i]; if(weapon >= 2 ) return PLUGIN_HANDLED; }
This doesnt work, I need some help pls
EDIT:
To explain it a lil better:
I need to use this function in the event: DeathMsg, its for an anti freekill system i'm working on.
To check if a victim has a primary weapon, so if the victim only had a knife AND he was not a rebel then i want to ignore the rest of the code in event: DeathMsg.
or in other words:
If the victim was not a rebel but had a primary weapon when he died (even if he wasnt holding that primary weapon) then i want to ignore the rest of the code.
This is how im using it now:
PHP Code:
public Event_DeathMsg() { new iKiller = read_data(1); new iVictim = read_data(2);
new freekill_slay = get_pcvar_num(jb_slay_4freekills) new max_freekills = get_pcvar_num(jb_max_freekills); new szVName[32], szKName[32]; get_user_name(iVictim, szVName, charsmax(szVName)); get_user_name(iKiller, szKName, charsmax(szKName));
clear_bit(g_bIsAlive, iVictim);
if( cs_get_user_team( iVictim ) == CS_TEAM_T ) { if( IsPlayer( iKiller ) && cs_get_user_team( iKiller ) == CS_TEAM_CT ) { if( g_bRebel[iVictim] ) { fnColorPrint(0, "Guard^4 %s ^1killed rebel^4 %s ^1!", szKName, szVName); } else if( !g_bRebel[iVictim] ) //if victim is not a rebel &&\/ { new Weapons[32]; new numWeapons, i, weapon; get_user_weapons(iVictim,Weapons, numWeapons); for (i=0; i<numWeapons; i++) { weapon = Weapons[i]; if(weapon >= 2 ) //if he has a primary weapon, then ignore the rest return PLUGIN_HANDLED; }
g_iFreekill[iKiller]++
if(g_iFreekill[iKiller] == 1) { fnColorPrint(iKiller, "^3Warning: ^1Freekilling is not allowed. "); UTIL_ScreenFade(iKiller,{ 255, 100, 61 }, 2.0, 2.0, 85); } if(g_iFreekill[iKiller] == 2) { UTIL_ScreenFade(iKiller,{ 255, 100, 61 }, 2.5, 2.5, 95); } if(g_iFreekill[iKiller] == freekill_slay) { fnColorPrint(iKiller, "^3Last warning:^1 Every freekill you make form now will result in instant slay"); UTIL_ScreenFade(iKiller,{ 255, 0, 0 }, 2.5, 2.5, 175); } if(g_iFreekill[iKiller] >= max_freekills) { //client_tutor(0, TutorRed, FriendDied, 6.0, "Freekilling is not allowed,^nType rules to see the rules."); UTIL_ScreenFade(iKiller,{ 255, 0, 0 }, 2.5, 2.5, 255); user_kill(iKiller); } } } } return PLUGIN_HANDLED; }