Check_Weapons(playerid)
{
new playerWeaponData[2][13];
for(new i = 0; i < 13; i++)
{
GetPlayerWeaponData(playerid, i, playerWeaponData[0][i], playerWeaponData[1][i]);
if(playerWeaponData[0][i] > 1)
{
SendClientMessage(playerid,COLOR_BLUE,"has weapons");
return 1;
}
}
return 0;
}
// [ DEVELOPMENT GAMEMODE ]
// INCLUDES:
#include <a_samp>
#include <zcmd>
// DEFINES:
// FUNCTIONS:
#define function%0(%1) forward%0(%1); public%0(%1)
// MAIN:
main()
{
print("Development Mode: weapon_check.amx");
}
// CALLBACKS:
public OnGameModeInit()
{
return 1;
}
public OnGameModeExit()
{
return 1;
}
// COMMANDS:
CMD:weaponcheck(playerid, params[])
{
if(DoesPlayerHaveWeapons(playerid)) SendClientMessage(playerid, -1, "You have weapons.");
else SendClientMessage(playerid, -1, "You do not have weapons.");
return 1;
}
CMD:giveweapon(playerid, params[])
{
GivePlayerWeapon(playerid, WEAPON_M4, 20);
return 1;
}
CMD:removeweapons(playerid, params[])
{
ResetPlayerWeapons(playerid);
return 1;
}
// FUNCTIONS:
function bool:DoesPlayerHaveWeapons(playerid)
{
new weapon[13], ammo[13], bool:found = false;
for(new i = 0; i < 13; i ++)
{
GetPlayerWeaponData(playerid, i, weapon[i], ammo[i]);
if(weapon[i] != 0 && ammo[i] >= 1)
{
found = true;
break;
}
}
return found;
}
new playerWeaponData[2][13]; --> new playerWeaponData[13][2];
Check_Weapons(playerid)
{
new weaponid, ammo;
for(new i = 0; i < 13; i++)
{
GetPlayerWeaponData(playerid, i, weaponid, ammo);
if(weaponid > 0) // here was > 1 but brass knuckles are weapon too
{
return 1; // No message here
}
}
return 0;
}
if(Check_Weapons(playerid) == 1)
{
SendClientMessage(playerid, -1, "has weapons");
return 1;
}
forward bool:DoesPlayerHaveWeapons(playerid);
public bool:DoesPlayerHaveWeapons(playerid)
{
new weap, am;
for(new i = 0; i < 13; i ++)
{
GetPlayerWeaponData(playerid, i, weap, am);
if(weap && am >= 1) return true;
}
return false;
}
pawn Код:
|
bool:DoesPlayerHaveWeapons(playerid)
{
new weap, am;
for(new i = 0; i < 13; i ++)
{
GetPlayerWeaponData(playerid, i, weap, am);
if(weap && am >= 1) return true;
}
return false;
}
pawn Код:
|
How is that better? You will get a warning (in a case), such as: C:\Users\... : warning 208: function with tag result used before definition, forcing reparse.
|
Throws no warnings for me at all, and I am sorry but is this 2006? I thought it was a known fact that using callbacks for your custom functions was a bad practice that only makes your script use more disk space and memory. If youre getting a warning it is because the function isn't being used in your script, either use it in your script somewhere or put stock infront of it. You shouldn't be using callbacks none the less.
|