forward MinigunTimer();
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/minigunevent", cmdtext, true, 10) == 0)
{
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
GivePlayerWeapon(playerid, 38, 999999);
}
}
SetTimer("SaveDataTimer",60000 , 0);
return 1;
}
}
public MinigunTimer()
{
foreach(new playerid : Player)
{
GivePlayerWeapon(playerid, 38, 0);
}
return 1;
}
#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
CMD:minigunevent(playerid)
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You are not admin"); //requires RCON, can be changed if you have a custom admin system
for(new i; i<MAX_PLAYERIS; i++)
{
if(IsPlayerConnected(i))
{
GivePlayerWeapon(playerid, 38, 999999);
}
}
SetTimer("RemoveMinigun", 60000, false);
SendClientMessageToAll(-1, "The minigun event has been activated by an admin!");
return 1;
}
forward RemoveMinigun();
public RemoveMiniGun()
{
for(new i; i>MAX_PLAYERS, i++)
{
if(GetPlayerWeapon(i) == 38)
{
ResetPlayerWeapons(i);
}
}
return 1;
}
coded in ZCMD.
pawn Код:
|
Nice One but ResetPlayerWeapons will remove ALL the weapons. Check this one
|
My code supports both total weapon resets and just minigun resets by changing true to false. So don't worry about posting any more code...
|