new DuelStarter=INVALID_PLAYER_ID;
new DuelEr=INVALID_PLAYER_ID;
new DuelStatus=0; // 0-net dueli, 1-priglashenie, 2-oba na dueli
new DuelTimer;
new Float:LastX[MAX_PLAYERS],Float:LastY[MAX_PLAYERS],Float:LastZ[MAX_PLAYERS];
new tim; onplayerdeath
[pwn]if((playerid == DuelStarter || playerid == DuelEr) && killerid == 255)
{
if(playerid == DuelStarter) SpawnPlayer(DuelEr);
else if(playerid == DuelEr) SpawnPlayer(DuelStarter);
DuelStarter=INVALID_PLAYER_ID;
DuelEr=INVALID_PLAYER_ID;
DuelStatus=0;
SendClientMessageToAll(COLOR_LIGHTBLUE, "*Дуэль отменена!");
}
if((playerid == DuelStarter || playerid == DuelEr) && (killerid == DuelStarter || killerid == DuelEr))
{
new winner[256], looser[256];
GetPlayerName(killerid, winner, sizeof(winner));
GetPlayerName(playerid, looser, sizeof(looser));
format(winner, sizeof(winner), "*Победил в дуэли: %s", winner);
format(looser, sizeof(looser), "Проиграл в дуэли: %s", looser);
SendClientMessageToAll(COLOR_LIGHTBLUE, winner);
SendClientMessageToAll(COLOR_LIGHTBLUE, looser);
GiveMoney(killerid, 10000);
SpawnPlayer(killerid);
DuelStarter=INVALID_PLAYER_ID;
DuelEr=INVALID_PLAYER_ID;
DuelStatus=0;
KillTimer(DuelTimer);
}
if((playerid == DuelStarter || playerid == DuelEr) && !(killerid == DuelStarter || killerid == DuelEr))
{
SendClientMessage(killerid, COLOR_RED, "*Не мешайте проведению дуэлей!");
SpawnPlayer(killerid);
if(playerid == DuelStarter) SpawnPlayer(DuelEr);
else if(playerid == DuelEr) SpawnPlayer(DuelStarter);
GiveMoney(killerid, -10000);
DuelStarter=INVALID_PLAYER_ID;
DuelEr=INVALID_PLAYER_ID;
DuelStatus=0;
KillTimer(DuelTimer);
}
[/pwn]
[pwn]forward DuelCheck();
public DuelCheck()
{
if(tim==2)
{
GameTextForPlayer(DuelStarter, "~b~3", 1000, 6);
GameTextForPlayer(DuelEr, "~b~3", 1000, 6);
PlaySound(DuelStarter, 1057);
PlaySound(DuelEr, 1057);
tim++;
}
if(tim==4)
{
GameTextForPlayer(DuelStarter, "~y~2", 1000, 6);
GameTextForPlayer(DuelEr, "~y~2", 1000, 6);
PlaySound(DuelStarter, 1057);
PlaySound(DuelEr, 1057);
tim++;
}
if(tim==6)
{
GameTextForPlayer(DuelStarter, "~g~1", 1000, 6);
GameTextForPlayer(DuelEr, "~g~1", 1000, 6);
PlaySound(DuelStarter, 1057);
PlaySound(DuelEr, 1057);
tim++;
}
if(tim==8)
{
GameTextForPlayer(DuelStarter, "~r~GO!!!", 1000, 6);
GameTextForPlayer(DuelEr, "~r~GO!!!", 1000, 6);
PlaySound(DuelStarter, 1058);
PlaySound(DuelEr, 1058);
tim=0;
TogglePlayerControllable(DuelStarter, 1);
TogglePlayerControllable(DuelEr, 1);
}
new Float:X, Float:Y, Float:Z;
GetPlayerPos(DuelStarter, X, Y, Z);
if(!(X <= 1137.3029 && X >= 1082.8479 && Y <= -872.2171 && Y >= -924.0237)) SetPlayerPos(DuelStarter, LastX[DuelStarter], LastY[DuelStarter], LastZ[DuelStarter]);
else
{
LastX[DuelStarter]=X;
LastY[DuelStarter]=Y;
LastZ[DuelStarter]=Z;
}
GetPlayerPos(DuelEr, X, Y, Z);
if(!(X <= 1137.3029 && X >= 1082.8479 && Y <= -872.2171 && Y >= -924.0237)) SetPlayerPos(DuelEr, LastX[DuelEr], LastY[DuelEr], LastZ[DuelEr]);
else
{
LastX[DuelEr]=X;
LastY[DuelEr]=Y;
LastZ[DuelEr]=Z;
}
return 1;
}[/pwn]
[pwn]SetDuel(playerid, weapon, ammo)
{
if(playerid==DuelStarter)
{
SetPlayerPos(playerid,1124.7782,-909.9190,58.1868);
SetPlayerFacingAngle(playerid, 40.0);
SetCameraBehindPlayer(playerid);
ResetPlayerWeapons(playerid);
SetPlayerWeapon(playerid, weapon, ammo);
DuelStatus=1;
TogglePlayerControllable(playerid, 0);
}
else if(playerid==DuelEr)
{
SetPlayerPos(playerid,1093.5872,-905.6541,58.1868);
SetPlayerFacingAngle(playerid, 310.0);
SetCameraBehindPlayer(playerid);
ResetPlayerWeapons(playerid);
SetPlayerWeapon(playerid, weapon, ammo);
DuelStatus=2;
TogglePlayerControllable(playerid, 0);
DuelTimer = SetTimer("DuelCheck", 500, true);
tim=2;
}
}[/pwn]
onplayercommandtext
[pwn]if(!strcmp(cmd, "/duel"))
{
if(DuelStatus == 2) return SendClientMessage(playerid, COLOR_GREEN, "*Дуэль уже идет!");
if(DuelStatus == 1 && DuelStarter == playerid) return SendClientMessage(playerid, COLOR_GRAD2, "*Вы на дуэли!");
if(DuelStatus == 0){
new gun[256];
gun = strtok(cmdtext, idx);
if(!strcmp(gun, "silencer")){ DuelStarter=playerid; SetDuel(playerid, 23, 120);}
else if(!strcmp(gun, "eagle")){ DuelStarter=playerid; SetDuel(playerid, 24, 120);}
else if(!strcmp(gun, "shotgun")){ DuelStarter=playerid; SetDuel(playerid, 25, 200);}
else if(!strcmp(gun, "mp5")){ DuelStarter=playerid; SetDuel(playerid, 29, 600);}
else if(!strcmp(gun, "AK")){ DuelStarter=playerid; SetDuel(playerid, 30, 700);}
else if(!strcmp(gun, "m4")){ DuelStarter=playerid; SetDuel(playerid, 31, 700);}
else return SendClientMessage(playerid, COLOR_GRAD2, "*Неправлильное оружие: eagle, shotgun, mp5, ak, m4");
//DuelStarter=playerid;
format(string, sizeof(string), "*Игрок %s приглашает на дуэль. Оружие: %s", db_GetPlayerName(playerid), gun);
SendClientMessageToAll(COLOR_BLUE, string);
//SetDuel(playerid);
return 1;
}
if(DuelStatus == 1 && DuelStarter != playerid)
{
new gun[256];
gun = strtok(cmdtext, idx);
if(!strcmp(gun, "silencer")){ DuelEr=playerid; SetDuel(playerid, 23, 120);}
else if(!strcmp(gun, "eagle")){ DuelEr=playerid; SetDuel(playerid, 24, 120);}
else if(!strcmp(gun, "shotgun")){ DuelEr=playerid; SetDuel(playerid, 25, 200);}
else if(!strcmp(gun, "mp5")){ DuelEr=playerid; SetDuel(playerid, 29, 600);}
else if(!strcmp(gun, "AK")){ DuelEr=playerid; SetDuel(playerid, 30, 700);}
else if(!strcmp(gun, "m4")){ DuelEr=playerid; SetDuel(playerid, 31, 700);}
else return SendClientMessage(playerid, COLOR_GRAD2, "*Неправлильное оружие: eagle, shotgun, mp5, ak, m4");
DuelEr=playerid;
format(string, sizeof(string), "*Игрок %s принял дуэль. Оружие: %s", db_GetPlayerName(playerid), gun);
SendClientMessageToAll(COLOR_BLUE, string);
//SetDuel(playerid);
return 1;
}
}[/pwn]
[pwn]stock PlaySound ( playerid, sound )
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
PlayerPlaySound(playerid, sound, X, Y, Z);
return sound;
}[/pwn]
[pwn]stock db_GetPlayerName(playerid)
{
new pl[24];
GetPlayerName(playerid, pl,24);
return pl;
}[/pwn]
если шо забыл говорите :D