/* Credits
RoyalEmpire
What's new?
> Added : Commands
> Admins CMD: /setdj, /kickdj
> /playsong
> /stopsong
> /dc
> /djsay
*/
#define FILTERSCRIPT
//Includes
#include <a_samp>
#include <zcmd>
#include <sscanf2>
//New defines
new djlvl[MAX_PLAYERS];
//Colours
#define COLOR_YELLOW 0xFFFF00FF
#define COLOR_RED 0xFF0000FF
#define COLOR_LBLUE 0x99FFFFFF
#define COLOR_WHITE 0xFFFFFFFF
//Credits
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Dj System by Royal Empire");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid)
{
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
CMD:setdj(playerid, params[])
{
new giveplayerid, giveplayer[25], playername[25], string[256];
if (sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /setdj [playerid]");
if (!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_RED, "Error: Inactive player id!");
GetPlayerName(giveplayerid, giveplayer, MAX_PLAYER_NAME);
if(djlvl[giveplayerid] > 0)
{
format(string, 64, "%s is already DJ", giveplayer);
SendClientMessage(playerid, COLOR_WHITE, string);
return 1;
}
else
{
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
djlvl[playerid] = 1;
format(string, 64, "You have been set as DJ.Use /djcmds for commands");
SendClientMessage(giveplayerid, COLOR_YELLOW, string);
format(string, 64, "You have set %s as a DJ member",giveplayer);
SendClientMessage(playerid,COLOR_YELLOW,string);
}
return 1;
}
CMD:kickdj(playerid, params[])
{
new giveplayerid, giveplayer[25], playername[25], string[256];
if (sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /kickdj [playerid]");
if (!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_RED, "Error: Inactive player id!");
GetPlayerName(giveplayerid, giveplayer, MAX_PLAYER_NAME);
if(djlvl[giveplayerid] < 1)
{
format(string, 64, "%s is already kicked from DJ", giveplayer);
SendClientMessage(playerid, COLOR_WHITE, string);
return 1;
}
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
djlvl[playerid] = 0;
format(string, 64, "You have been kicked from a DJ");
SendClientMessage(giveplayerid, COLOR_RED, string);
format(string, 64, "You have kicked %s from a DJ",giveplayer);
SendClientMessage(playerid,COLOR_YELLOW,string);
return 1;
}
CMD:dc(playerid, params[])
{
new playername[25],tmp[256];
if(djlvl[playerid] < 1) return 1;
if(sscanf(params, "s[256]", tmp)) return SendClientMessage(playerid, -1, "[Usage]: /dc [message]");
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
format(tmp, sizeof(tmp), "{99FFFF}[DJ Chat]{FFFFFF} %s: %s", playername, tmp);
for(new i = 0 ; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && djlvl[i] != 0) SendClientMessage(i,COLOR_WHITE,tmp);
}
return 1;
}
CMD:djsay(playerid, params[])
{
new tmp[256], playername[25], tmp2[256],string[256];
if (djlvl[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "Error: You aren't a DJ member.");
if (sscanf(params, "s[128]", tmp)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /djsay [message]");
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
if (djlvl[playerid] == 1)
{
format(tmp2, sizeof(tmp2), "say %s", tmp);
format(string, sizeof(string), "* DJ Member: %s", tmp);
SendClientMessageToAll(COLOR_LBLUE, string);
}
printf("[ssay] %s: %s", playername, tmp);
return 1;
}
CMD:djcmds(playerid, params[])
{
if(djlvl[playerid] == 1)
{
SendClientMessage(playerid,COLOR_RED,"|||||===== DJ COMMANDS =====|||||");
SendClientMessage(playerid,COLOR_LBLUE,"/playsong, /stopsong, /dc, /djsay");
}
return 1;
}
CMD:requestsong(playerid, params[])
{
new playername[25],tmp[256];
if(sscanf(params, "s[256]", tmp)) return SendClientMessage(playerid, -1, "[Usage]: /requestsong [Song name]");
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
format(tmp, sizeof(tmp), "{99FFFF}[ Song Request ]%s: %s", playername, tmp);
for(new i = 0 ; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && djlvl[i] != 0) SendClientMessage(i,COLOR_WHITE,tmp);
}
return 1;
}
CMD:stopsong(playerid, params[])
{
new string[256], playername[25];
if(djlvl[playerid] < 1) return 0;
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
format(string, sizeof(string), "{99FFFF}[DJ]{FFFFFF} %s: Stoped a song.", playername);
if(adlvl[playerid]> 1)
{
format(string, sizeof(string), "{99FFFF}[Admin]{FFFFFF} %s Had Stoped The Song.", playername);
}
SendClientMessageToAll2(0xFFFFFFAA,string);
for(new i = 0; i < PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
StopAudioStreamForPlayer(i);
}
}
return 1;
}
CMD:playsong(playerid, params[])
{
new string[256], playername[25], song[256];
if(djlvl[playerid] < 1) return 0;
if(sscanf(params, "s[256]", song)) return SendClientMessage(playerid, -1, "Usage: /playsong [url]");
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
format(string, sizeof(string), "{99FFFF}[DJ]{FFFFFF} %s has played a song.", playername);
if(adlvl[playerid]> 1)
{
format(string, sizeof(string), "{99FFFF}%s has played a song.", playername);
}
SendClientMessageToAll2(0xFFFFFFAA,string);
for(new i = 0 ; i < PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
PlayAudioStreamForPlayer(i, song);
}
}
return 1;
}
CMD:setdj(playerid, params[])
{
new player, djlvl;
else if(sscanf(params, "ui", playerid, djlvl)) return SendClientMessage(playerid, -1, "Usage: /setdj [id] [0 - remove, 1-setdj]");
else if(djlvl < 0 || djlvl > 1) return SendClientMessage(playerid, -1, "Only levels 0-1");
else if(player == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Player Is Not Currently Connected");
else
{
new string[128], string1[128], target[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME];
GetPlayerName(player, pName, sizeof(pName));
GetPlayerName(playerid, target, sizeof(target));
format(string, sizeof(string), "You have set %s DJ Member to %i", target, djlvl);
SendClientMessage(playerid, -1, string);
format(string, sizeof(string), "You has been set as DJ %i by %s", djlvl, pName);
SendClientMessage(player, -1, string1);
PlayerInfo[player][pDJ] = djlvl;
}
return 1;
}