Duel System DKN | /duel [playerid] -
ipsBruno - 29.08.2010
[FS] Duel System By DraKoN
Introduction:
Is a Duel System..
Due to some people want one Duel System ,I post here my project that was collaborated by my friend JONA
Code:
Due to the code is small, just simply modify here down
Code:
//-> Go To X1 <-//
//SetPlayerPos -> Go To You Arena
//SetPlayerArmor -> Give Armour
//SetPlayerHealth -> Give Health
// Or Others
Obs: PID = Player 2 |
PLAYERID = Player 1
Here Code:
pawn Code:
#include <a_samp>
#define DIALOG_DUEL 24245
new bool:InvitedDuel[MAX_PLAYERS];
new IdDuel[MAX_PLAYERS];
new bool:UsingArena;
new Counting = 5;
new CountDueling[5][5] ={"~r~1","~b~2","~p~3","~y~4","~g~5"};
forward ExecuteCount(playerid,pid);
public ExecuteCount(playerid,pid)
{
if (Counting > 0)
{
GameTextForPlayer(playerid,CountDueling[Counting-1], 2500, 3);
GameTextForPlayer(pid,CountDueling[Counting-1], 1000, 3);
Counting--;
SetTimerEx("GoDuel",1000,false,"ii",playerid,pid);
}
else
{
GameTextForPlayer(playerid,"~>~~g~Go~w~Go~r~Go~b~Go~<~", 2500, 3);
GameTextForPlayer(pid,"~>~~g~Go~w~Go~r~Go~b~Go~<~", 2500, 3);
Counting = 5;
TogglePlayerControllable(playerid,true);
TogglePlayerControllable(pid,true);
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128];
new idx;
new id;
cmd = otherplayerids(cmdtext, idx);
if(!strcmp("/duel", cmd, true))
{
new tmp[128];
new string[128];
tmp = otherplayerids(cmdtext, idx);
id = strval(tmp);
if(InvitedDuel[playerid] == true) return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Have you invited someone, wait Expire Invitation");
if(UsingArena == true) return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : At the time the Arena is Being Used");
if(!strlen(tmp)) return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : You must enter the ID of the player following the Way (/duel [playerid])");
if(id == playerid) return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : You can not invite the Self");
if(InvitedDuel[id] == true) return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Currently the player is in a Duel, wait..");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "»»[DUEL]«« : %s This inviting you to a \n Duel Runing (Press Accept to Accept Duel)",name);
ShowPlayerDialog(id,DIALOG_DUEL,DIALOG_STYLE_MSGBOX,"»»[DUEL]«« :",string,"Accept", "No");
GameTextForPlayer(id,"~r~DUE~w~LO !", 2500, 3);
InvitedDuel[id] = true;
IdDuel[id] = playerid;
SetTimerEx("ExpireDuel",15000,false,"ii",id,playerid);
return 1;
}
return 0;
}
forward GoDuel(playerid,pid);
public GoDuel(playerid,pid)
{
//-> Go To X1 <-//
//SetPlayerPos
//SetPlayerArmor
//SetPlayerHealth
//-> Functions for Count x1<-//
TogglePlayerControllable(playerid,false);
TogglePlayerControllable(pid,false);
ExecuteCount(playerid,pid);
return 1;
}
forward ExpireDuel(playerid,pid);
public ExpireDuel(playerid,pid)
{
if(UsingArena == false)
{
SendClientMessage(pid,0x1DF6F6AA,"»»[DUEL]«« : Expired challenge, He Refused");
SendClientMessage(playerid,0x1DF6F6AA,"»»[DUEL]«« : Expired challenge, you automatically refuse");
InvitedDuel[pid] = false;
InvitedDuel[playerid] = false;
IdDuel[playerid] = playerid;
IdDuel[pid] = pid;
}
return 1;
}
otherplayerids(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_DUEL)
{
if(!response) return ExpireDuel(playerid,IdDuel[playerid]);
if(response)
{
UsingArena = true;
new name[MAX_PLAYER_NAME], string[44];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "»»[DUEL]«« : %s accepted the challenge, wait 8 seconds to go to Duel.",name);
SendClientMessage(IdDuel[playerid],0xF6F600AA,string);
SendClientMessage(playerid,0xF6F600AA,"»»[DUEL]«« : You accepted the Duel Wait 8 seconds to process your Data");
SetTimerEx("GoDuel",8000,false,"ii",playerid,IdDuel[playerid]);
}
return 1;
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(InvitedDuel[killerid] == true)
{
new Float:healthkiller;
new namekiller[24],namedeather[24],string[44];
GetPlayerName(killerid, namekiller, 24);
GetPlayerName(playerid, namedeather, 24);
GetPlayerHealth(killerid,healthkiller);
format(string, sizeof(string), "»»[DUELO]«« : %s Wins Duel of %s how %0.0f off Armour and Health",namekiller,namedeather,healthkiller);
SendClientMessageToAll(0xF600F6AA, string);
InvitedDuel[killerid] = false;
InvitedDuel[playerid] = false;
IdDuel[playerid] = playerid;
IdDuel[killerid] = killerid;
UsingArena = false;
healthkiller = 0;
SpawnPlayer(killerid);
}
return 1;
}
Obs: I advise you add this to GameMode, because it conflicts
Hpe you like my simple system Duels is a pleasure share here ...
CREDITS FOR JONA AND DRAKON
Re: Duel System DKN | /duel [playerid] -
nuriel8833 - 29.08.2010
Great job!
Re : Duel System DKN | /duel [playerid] -
Varkoll_ - 29.08.2010
good job man !!
Respuesta: Duel System DKN | /duel [playerid] -
ipsBruno - 24.12.2010
Released
/duel [id] [wep1] [wep2]
Thankz to LethaL
pawn Code:
#include <a_samp>
#define DIALOG_DUEL 24245
new
bool:InvitedDuel[MAX_PLAYERS],
IdDuel[MAX_PLAYERS],
wep1[MAX_PLAYERS],
wep2[MAX_PLAYERS],
bool:UsingArena,
Counting = 5,
CountDueling[5][5] ={"~r~1","~b~2","~p~3","~y~4","~g~5"}
;
forward ExecuteCount(playerid,pid);
public ExecuteCount(playerid,pid)
{
if (Counting > 0)
{
GameTextForPlayer(playerid,CountDueling[Counting-1], 2500, 3);
GameTextForPlayer(pid,CountDueling[Counting-1], 1000, 3);
Counting--;
SetTimerEx("GoDuel",1000,false,"ii",playerid,pid);
}
else
{
GameTextForPlayer(playerid,"~>~~g~Go~w~Go~r~Go~b~Go~<~", 2500, 3);
GameTextForPlayer(pid,"~>~~g~Go~w~Go~r~Go~b~Go~<~", 2500, 3);
Counting = 5;
TogglePlayerControllable(playerid,true);
TogglePlayerControllable(pid,true);
}
return true;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128],idx;
cmd = strtok(cmdtext, idx);
if(!strcmp("/duel", cmd, true))
{
new id,tmp[3][80],w1,w2,string[128];
tmp[0] = strtok(cmdtext, idx);
tmp[1] = strtok(cmdtext, idx);
tmp[2] = strtok(cmdtext, idx);
id = strval(tmp[0]);
w1 = strval(tmp[1]);
w2 = strval(tmp[2]);
if(InvitedDuel[playerid] == true)
return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Have you invited someone, wait Expire Invitation");
if(UsingArena == true)
return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : At the time the Arena is Being Used");
if(!IsValidWeapon(w1) || !IsValidWeapon(w2))
return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Use Valids Weapons IDs");
if(!strlen(tmp[1]) || !strlen(tmp[2]))
return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Use /duel [id] [wep1] [wep2]");
if(!strlen(tmp[0]))
return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : You must enter the ID of the player following the Way (/duel [playerid])");
if(id == playerid)
return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : You can not invite the Self");
if(InvitedDuel[id] == true)
return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Currently the player is in a Duel, wait..");
new name[24];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "»»[DUEL]«« : %s This inviting you to a \n Duel Runing (Press Accept to Accept Duel)",name);
ShowPlayerDialog(id,DIALOG_DUEL,DIALOG_STYLE_MSGBOX,"»»[DUEL]«« :",string,"Accept", "No");
GameTextForPlayer(id,"~r~DUE~w~LO !", 2500, 3);
IdDuel[id] = playerid;
wep1[id] = w1;
wep2[id] = w2;
SetTimerEx("ExpireDuel",15000,false,"ii",id,playerid);
return true;
}
return false;
}
forward GoDuel(playerid,pid,w1,w2);
public GoDuel(playerid,pid,w1,w2)
{
//-> Go To X1 <-//
//SetPlayerPos
//SetPlayerArmor
//SetPlayerHealth
//-> Functions for Count x1<-//
GivePlayerWeapon(playerid,w1,999999);
GivePlayerWeapon(playerid,w2,999999);
GivePlayerWeapon(pid,w1,999999);
GivePlayerWeapon(pid,w2,999999);
InvitedDuel[playerid] = true;
InvitedDuel[pid] = true;
TogglePlayerControllable(playerid,false);
TogglePlayerControllable(pid,false);
ExecuteCount(playerid,pid);
return true;
}
forward ExpireDuel(playerid,pid);
public ExpireDuel(playerid,pid)
{
if(UsingArena == false)
{
SendClientMessage(pid,0x1DF6F6AA,"»»[DUEL]«« : Expired challenge, He Refused");
SendClientMessage(playerid,0x1DF6F6AA,"»»[DUEL]«« : Expired challenge, you automatically refuse");
InvitedDuel[pid] = false;
InvitedDuel[playerid] = false;
IdDuel[playerid] = playerid;
IdDuel[pid] = pid;
}
return true;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_DUEL)
{
if(!response) return ExpireDuel(playerid,IdDuel[playerid]);
if(response)
{
UsingArena = true;
new name[MAX_PLAYER_NAME], string[44];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "»»[DUEL]«« : %s accepted the challenge, wait 8 seconds to go to Duel.",name);
SendClientMessage(IdDuel[playerid],0xF6F600AA,string);
SendClientMessage(playerid,0xF6F600AA,"»»[DUEL]«« : You accepted the Duel Wait 8 seconds to process your Data");
SetTimerEx("GoDuel",8000,false,"ii",playerid,IdDuel[playerid],wep1[playerid],wep2[playerid]);
}
return true;
}
return true;
}
public OnPlayerDisconnect(playerid,reason)
{
if(InvitedDuel[playerid] == true)
{
for(new killerid; killerid < MAX_PLAYERS; killerid++) if(IsPlayerConnected(killerid) && InvitedDuel[killerid] == true)
{
new Float:healthkiller;
new namekiller[24],namedeather[24],string[44];
GetPlayerName(killerid, namekiller, 24);
GetPlayerName(playerid, namedeather, 24);
GetPlayerHealth(killerid,healthkiller);
format(string, sizeof(string), "»»[DUELO]«« : %s Wins Duel of %s how %0.0f off Armour and Health",namekiller,namedeather,healthkiller);
SendClientMessageToAll(0xF600F6AA, string);
InvitedDuel[killerid] = false;
InvitedDuel[playerid] = false;
IdDuel[playerid] = playerid;
IdDuel[killerid] = killerid;
UsingArena = false;
healthkiller = 0;
SpawnPlayer(killerid);
}
}
return true;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(InvitedDuel[killerid] == true)
{
new Float:healthkiller;
new namekiller[24],namedeather[24],string[44];
GetPlayerName(killerid, namekiller, 24);
GetPlayerName(playerid, namedeather, 24);
GetPlayerHealth(killerid,healthkiller);
format(string, sizeof(string), "»»[DUELO]«« : %s Wins Duel of %s how %0.0f off Armour and Health",namekiller,namedeather,healthkiller);
SendClientMessageToAll(0xF600F6AA, string);
InvitedDuel[killerid] = false;
InvitedDuel[playerid] = false;
IdDuel[playerid] = playerid;
IdDuel[killerid] = killerid;
UsingArena = false;
healthkiller = 0;
SpawnPlayer(killerid);
}
return true;
}
IsValidWeapon(weaponid)
{
new badWeapon[21] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 40, 44, 45, 46};
for(new i=0; i <20; i++)
if (weaponid == badWeapon[i])
return false;
return true;
}
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
Re: Duel System DKN | /duel [playerid] -
HyperZ - 24.12.2010
Nice job dude.
Re: Duel System DKN | /duel [playerid] - [L3th4l] - 24.12.2010
Great! Thanks DraKiNs!!
Merry Christmas!
Re: Duel System DKN | /duel [playerid] -
OGganza - 02.01.2011
Nice Code dude, but for example, if i wanted to, add 3 more arenas(to have a total of 4 arenas), what would i need to do in order for it to be like:
ID 1 is Dueling with ID 0, and then (while the duel is still happening), ID 2 challenges ID 3 to a duel, and in case he accepts they(IDs 2 and 3) get teleported to the duel but instead of going to the same arena that IDs 0 and 1 are, they go to the second arena, and so on and so on.
thx anyway and once again nice code.
Re: Duel System DKN | /duel [playerid] -
endjuru - 02.01.2011
Hmmm,ANAWAY I LOVE THIS SCRIPT I USING THIS
!
Re: Duel System DKN | /duel [playerid] -
Lorenzo* - 14.07.2012
nice, great for those 1v1 situations when you just hate them from how they talk :S
Re: Duel System DKN | /duel [playerid] -
Dasharkishanjan5 - 28.07.2012
Good.
Re: Duel System DKN | /duel [playerid] -
Filbert - 22.05.2018
can duel started more than 1 at the same time?