PHP код:
OnPlayerDeath
if(InDuel[playerid] == 1)
{
new msg[128];
format(msg, sizeof(msg), "Duel Between %s (%d) and %s (%d) Has Ended. Reason: {ff0000}Player Died!", PlayerInfo[DuelPlayer1][pName], DuelPlayer1, PlayerInfo[DuelPlayer2][pName], DuelPlayer2);
SendClientMessageToAll(COLOR_SERVER_HELP_MSG, msg);
Progress = 0;
InDuel[DuelPlayer1] = 0;
InDuel[DuelPlayer2] = 0;
KillTimer(DUEL_TIMER);
SpawnPlayer(DuelPlayer1);
SetPlayerVirtualWorld(DuelPlayer1, 0);
SpawnPlayer(DuelPlayer2);
SetPlayerVirtualWorld(DuelPlayer2, 0);
}
if(InDuel[playerid] == 1 && InDuel[killerid] == 1)
{
GiveCash(killerid, 2*Bet);
new Float:Health, Float:Armour1, string1[128];
GetPlayerArmour(killerid, Armour1);
GetPlayerHealth(killerid, Health);
format(string1, sizeof(string1), "[DUEL] %s (%d) Has Won The Duel From %s (%d) And Still Has %.2f {ff0000}Health Left.", PlayerInfo[killerid][pName], killerid, PlayerInfo[playerid][pName], playerid, Health);
SendClientMessageToOthers(killerid,COLOR_SERVER_HELP_MSG, string1);
new str[128];
format(str, sizeof(str), "[DUEL]: You Have Won The Duel Against %s (%d) And Gained {ff0000}$%d.", PlayerInfo[playerid][pName], playerid, Bet);
SendClientMessage(killerid, COLOR_SERVER_HELP_MSG, str);
PlayerInfo[killerid][pDuelsWon] ++;
PlayerInfo[playerid][pDuelsLost] ++;
SpawnPlayer(killerid);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerVirtualWorld(killerid, 0);
Progress = 0;
InDuel[playerid] = 0;
InDuel[killerid] = 0;
SetPlayerVirtualWorld(playerid, 0);
SetPlayerVirtualWorld(killerid, 0);
KillTimer(DUEL_TIMER);
return 1;
}
PHP код:
COMMAND:aduel(playerid,params[])
{
new idx;
new tmp[256]; tmp = strtok(params,idx);
new tmp2[256]; tmp2 = strtok(params,idx);
if(PlayerInfo[playerid][pAdminlevel] > 0)
{
if(!strlen(tmp) || !strlen(tmp2))
{
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /aduel [playerid 1] [playerid 2]");
return 1;
}
new TargetID = strval(tmp);
new TargetID2 = strval(tmp2);
new string[256];
if(TargetID == TargetID2)
{
SendClientMessage(playerid, COLOR_ERROR, "You Need to Write 2 Different ID.");
return 1;
}
if(!IsPlayerConnected(TargetID2))
{
SendClientMessage(playerid, COLOR_ERROR, "ERROR: Player Two is Not Connected");
return 1;
}
SetPlayerInterior(playerid, 1);
SetPlayerPos(playerid, 1374.0948,5.5511,1008.1563);
SetPlayerInterior(TargetID, 1);
SetPlayerPos(TargetID,1413.1495,-15.9198,1000.9246);
SetPlayerInterior(TargetID2, 1);
SetPlayerPos(TargetID2,1367.6084,-17.7317,1000.9219);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerVirtualWorld(TargetID, 0);
SetPlayerVirtualWorld(TargetID2, 0);
format(string, sizeof(string), "In Duel Challenge");
strmid(PlayerInfo[TargetID][pInteriorName], string, 0, strlen(string), 256);
strmid(PlayerInfo[TargetID][pLocation], string, 0, strlen(string), 256);
format(string, sizeof(string), "In Duel Challenge");
strmid(PlayerInfo[TargetID2][pInteriorName], string, 0, strlen(string), 256);
strmid(PlayerInfo[TargetID2][pLocation], string, 0, strlen(string), 256);
counttime[TargetID] = 5;
SetTimerEx("Duel",1000,0,"dd", TargetID, TargetID2);
format(string, sizeof(string), "***An Admin Has Started a 1v1 Private Duel Between %s (%d) and %s (%d).",PlayerInfo[TargetID][pName],TargetID,PlayerInfo[TargetID2][pName],TargetID2);
SendClientMessageToOthers(playerid, COLOR_ADMIN, string);
format(string, sizeof(string), "***An Admin Has Started a 1v1 Duel Between You and %s (%d).",PlayerInfo[TargetID2][pName],TargetID2);
SendClientMessage(TargetID, COLOR_ADMIN, string);
format(string, sizeof(string), "***An Admin Has Started a 1v1 Duel Between You and %s (%d).",PlayerInfo[TargetID][pName],TargetID);
SendClientMessage(TargetID2, COLOR_ADMIN, string);
}else{
SendClientMessage(playerid,COLOR_ERROR,""ERROR_MSG"");
}
return 1;
}
COMMAND:duel(playerid, params[])
{
new TargetID, DuelBet;
if(sscanf(params, "ui", TargetID, DuelBet))
{
SendClientMessage(playerid, COLOR_ERROR,"USAGE: /duel [PlayerID] [Bet]");
return 1;
}
if(!IsPlayerConnected(TargetID) || TargetID == INVALID_PLAYER_ID)
{
SendClientMessage(playerid, COLOR_ERROR, "That Player Is Not Connected.");
return 1;
}
if(InSniper[playerid] == 1)
{
SendClientMessage(playerid,COLOR_ERROR,"You Cannot Use This Command In Sniper DM.");
return 1;
}
if(DuelAllowed[playerid] == 0)
{
SendClientMessage(playerid, COLOR_ERROR, "You Must Have to Allow Duels In Order To Invite Some 1 For Duel.");
return 1;
}
if(DuelAllowed[TargetID] == 0)
{
SendClientMessage(playerid, COLOR_ERROR, "That Player Has His Duel Invitations OFF.");
return 1;
}
if(Progress == 2)
{
SendClientMessage(playerid, COLOR_ERROR, "Duel Is In Progress");
return 1;
}
if(Progress == 1)
{
SendClientMessage(playerid, COLOR_ERROR,"Someone Is Inviting Someone else To A Duel, Please Wait..");
return 1;
}
if(GetPlayerCash(playerid) < DuelBet && DuelBet != 0)
{
SendClientMessage(playerid, COLOR_ERROR, "You Don't Have That Much Money.");
return 1;
}
if(GetPlayerCash(TargetID) < DuelBet && DuelBet != 0)
{
SendClientMessage(playerid, COLOR_ERROR, "That Player Doesn't Have That Much Amount of Money!");
return 1;
}
if(DuelBet < 1000 || DuelBet > 250000)
{
SendClientMessage(playerid, COLOR_ERROR, "Bet Range: $1000 - 250000.");
return 1;
}
if(TargetID == playerid)
{
SendClientMessage(playerid, COLOR_ERROR, "You Cannot Duel Yourself.");
return 1;
}
DuelPlayer2 = TargetID;
DuelPlayer1 = playerid;
Bet = DuelBet;
Progress = 1;
ShowPlayerDialog(playerid, dueldialog + 1 , DIALOG_STYLE_LIST, "{00ff2a}Duel Weapons:", "{FFFFFF}Sawn-off Shotgun\nDesert Eagle\nTEC-9\nM4\nAk47\nColt-45 / 9mm\nSawn-off Shotgun + TEC-9 + Deagle\nM4 + Deagle\nSniper + M4", "Choose", "Cancel");
return 1;
}
COMMAND:acduel(playerid, params[])
{
return cmd_acceptduel(playerid, params);
}
COMMAND:acceptduel(playerid, params[])
{
new string[256];
if(PlayerInfo[playerid][pSpawned] == 1)
{
if(InDuel[playerid] == 1)
{
SendClientMessage(playerid,COLOR_ERROR,"You Are Already in Duel Challenge.");
return 1;
}
if(DuelOffer[playerid] == 1)
{
format(string, sizeof(string), "[DUEL] The Duel Between %s (%d) and %s (%d) Has Started. (Bet: $%d)", PlayerInfo[DuelPlayer1][pName], DuelPlayer1, PlayerInfo[DuelPlayer2][pName], DuelPlayer2, Bet);
SendClientMessageToAll(COLOR_SERVER_HELP_MSG, string);
SetPlayerPosEx(DuelPlayer1,DuelPlace1,199.2980,16,0);
SetPlayerPosEx(DuelPlayer2,DuelPlace2,23.5397, 16,0);
SetPlayerHealth(DuelPlayer1, 100);
SetPlayerHealth(DuelPlayer2, 100);
SetPlayerArmour(DuelPlayer1, 100);
SetPlayerArmour(DuelPlayer2, 100);
format(string, sizeof(string), "In Duel Challenge");
strmid(PlayerInfo[DuelPlayer1][pInteriorName], string, 0, strlen(string), 256);
strmid(PlayerInfo[DuelPlayer1][pLocation], string, 0, strlen(string), 256);
format(string, sizeof(string), "In Duel Challenge");
strmid(PlayerInfo[DuelPlayer2][pInteriorName], string, 0, strlen(string), 256);
strmid(PlayerInfo[DuelPlayer2][pLocation], string, 0, strlen(string), 256);
GiveCash(DuelPlayer1, -Bet);
GiveCash(DuelPlayer2, -Bet);
SetPlayerVirtualWorld(DuelPlayer1, 2);
SetPlayerVirtualWorld(DuelPlayer2, 2);
TogglePlayerControllable(DuelPlayer1, false);
TogglePlayerControllable(DuelPlayer2, false);
SetCameraBehindPlayer(DuelPlayer1);
SetCameraBehindPlayer(DuelPlayer2);
InDuel[DuelPlayer1] = 1;
InDuel[DuelPlayer2] = 1;
Progress = 2;
GiveDuelWeapons(DuelType);
PlayerInfo[DuelPlayer1][pDrugsTime] = 0;
PlayerInfo[DuelPlayer2][pDrugsTime] = 0;
ON_DRUGS[DuelPlayer1] = 0;
ON_DRUGS[DuelPlayer2] = 0;
DrugsTaken[DuelPlayer1] = 0;
DrugsTaken[DuelPlayer2] = 0;
CD = 6;
CDTimer = SetTimer("CountDown", 1000, 1);
KillTimer(declinedueltimer);
DUEL_TIMER = SetTimer("TIMEUP", 60000*3, 0);
}else{
SendClientMessage(playerid,COLOR_ERROR,"You Cannot Accept Duel, No One Sent You Duel Challenge.");
}
}else{
SendClientMessage(playerid, COLOR_ERROR, "You Cannot Use This Command While You're Dead.");
}
return 1;
}
COMMAND:refuseduel(playerid, params[])
{
if(PlayerInfo[playerid][pSpawned] == 1)
{
if(DuelOffer[playerid] == 1)
{
DuelDeclined();
}else{
SendClientMessage(playerid,COLOR_ERROR,"You Cannot Refuse Duel, No One Sent You Duel Challenge.");
}
}else{
SendClientMessage(playerid, COLOR_ERROR, "You Cannot Use This Command While You're Dead.");
}
return 1;
}