14.12.2011, 18:47
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[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ERROR, "You are not Admin!");
/*
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ERROR, "Message");
* Note: ! means not. If someone isn't logged in as Rcon Administrator, he/she will get a message that he/she is not Admin!
For Lux's Admin System it's:
if(AccInfo[playerid][Level] < 3) return SendClientMessage(playerid, COLOR_ERROR, "Message");
You can change the 3 to any level you want.
*/
new
string[120],
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(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ERROR, "You are not Admin!");
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[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ERROR, "You are not Admin!");
new
pname[24],
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[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ERROR, "You are not Admin!");
new
weapon,
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;
}
/*
However,
CMD:command(playerid, params[]) is same as cmd(command, playerid, params[]), but your way is older :P
If you want change them back.
*/