25.02.2014, 23:19
pawn Код:
#include <a_samp>
#include <zcmd>
#define REMOVEMINIGUN true //Change this to 'false' if you want to remove all weapons the end of the event.
new bool:MinigunEvent;
public OnGameModeInit()
{
MinigunEvent = false;
return 1;
}
CMD:minigunevent(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You must be an RCON Admin to use this command.");
if(MinigunEvent) return SendClientMessage(playerid, 0xFF0000FF, "There is already a minigun event running. Wait for it to finish.");
for(new i = 0; i < MAX_PLAYERS; i++) //Foreach is recommended here...
{
if(!IsPlayerConnected(i)) continue;
GivePlayerWeapon(i, 38, 5000); //Gives a minigun with 5000 ammo.
}
MinigunEvent = true;
SetTimer("ResetMinigunEvent", 60000, false); //Sets a timer for 60 seconds (1 minute).
SendClientMessageToAll(0xFFFF00FF, "A Minigun Event has begun. It will end in 1 minute.");
return 1;
}
forward ResetMinigunEvent();
public ResetMinigunEvent()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
#if REMOVEMINIGUN == true
RemovePlayerWeapon(i, 38);
#else
ResetPlayerWeapons(i);
#endif
}
MinigunEvent = false;
return 1;
}
#if REMOVEMINIGUN == true
stock RemovePlayerWeapon(playerid, weaponid)
{
new plyWeapons[12];
new plyAmmo[12];
for(new slot = 0; slot != 12; slot++)
{
new wep, ammo;
GetPlayerWeaponData(playerid, slot, wep, ammo);
if(wep != weaponid)
GetPlayerWeaponData(playerid, slot, plyWeapons[slot], plyAmmo[slot]);
}
ResetPlayerWeapons(playerid);
for(new slot = 0; slot != 12; slot++)
GivePlayerWeapon(playerid, plyWeapons[slot], plyAmmo[slot]);
return 1;
}
#endif