14.12.2011, 16:21
pawn Код:
/*
Includes files.
Located on your_server\pawno\include
*/
#include <a_samp>
#include <zcmd>
#include <sscanf>
#include <dudb>
#include <gvar>
#include <time>
#include <dprops>
#pragma unused strtok
/*
OnFilterScriptInit() Callback.
*/
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Event System");
print("--------------------------------------\n");
return 1;
}
/*
Commands with ZCMD
* Note: Commands with ZCMD should be outside callbacks.
Never use it with OnPlayerCommandText(playerid, cmdtext[]) callback.
The result will be an error 029: invalid expression, assumed zero.
*/
cmd(startevent, playerid, params[])
{
new string[120]; new pname[24]; GetPlayerName(playerid, pname, 24);
if(GetPVarInt(playerid, "AdminLevel") == 0) return SendClientMessage(playerid, COLOR_ERROR, "Invalid Command. Read /commands.");
if(GetPVarInt(playerid, "Jailed") == 1) return SendClientMessage(playerid, COLOR_ERROR, "You cannot use this command while in jail.");
if(GetPVarInt(playerid, "Cuffed") == 1) return SendClientMessage(playerid, COLOR_ERROR, "You cannot use this command while cuffed.");
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
SetGVarFloat("EventX", x); SetGVarFloat("EventY", y); SetGVarFloat("EventZ", z); SetGVarInt("EventI", GetPlayerInterior(playerid)); SetGVarInt("EventStarted", 1);
format(string, 120, "[ADMIN EVENT] Server Admin %s(%d) has started an event. Type /event to join.", pname, playerid);
SendClientMessageToAll(COLOR_ADMIN, string);
IRC_Say(gGroupID, IRC_CHANNEL, string);
SendClientMessage(playerid, COLOR_GREEN, "You have started an event. Type /endevent to end it.");
return 1;
}
cmd(event, playerid, params[])
{
if(GetGVarInt("EventStarted") == 0) return SendClientMessage(playerid, COLOR_ERROR, "There's no event started.");
SendClientMessage(playerid, COLOR_GREEN, "You have joined the Admin Event.");
SetPlayerPos(playerid, GetGVarFloat("EventX"), GetGVarFloat("EventY"), GetGVarFloat("EventZ"));
SetPlayerInterior(playerid, GetGVarInt("EventI"));
SetPVarInt(playerid, "InEvent", 1);
return 1;
}
cmd(endevent, playerid, params[])
{
new pname[24]; new string[120]; GetPlayerName(playerid, pname, 24);
if(GetPVarInt(playerid, "AdminLevel") == 0) return SendClientMessage(playerid, COLOR_ERROR, "Invalid Command. Read /commands");
if(GetGVarInt("EventStarted") == 0) return SendClientMessage(playerid, COLOR_ERROR, "There's no event started.");
SetGVarInt("EventStarted", 0);
format(string, 120, "[ADMIN EVENT] Admin %s(%d) has ended the current event. You can no longer join.", pname, playerid);
SendClientMessage(playerid, COLOR_ADMIN, string);
return 1;
}
cmd(eventweapon, playerid, params[])
{
new weapon; new ammo;
if(GetPVarInt(playerid, "AdminLevel") == 0) return SendClientMessage(playerid, COLOR_ERROR, "Invalid Command.");
//if(GetGVarInt("EventStarted") == 0) return SendClientMessage(playerid, COLOR_ERROR, "There's no event started.");
if(sscanf(params, "ii", weapon, ammo)) return SendClientMessage(playerid, COLOR_ERROR, "Usage: /eventweapon (WeaponID) (Ammo)");
for(new i = 0; i<MAX_PLAYERS; i ++)
{
if(GetPVarInt(i, "InEvent") == 1)
{
GivePlayerWeapon(i, weapon, ammo);
SendClientMessage(i, COLOR_ADMIN, "You have been given an event weapon.");
SendClientMessage(playerid, COLOR_ADMIN, "You have given everyone at the event an event weapon.");
}
}
return 1;
}