25.08.2013, 03:22
hey guys, I wanna ask you guys something.
I was going to make simple duel system. And below is my whole code for this case:
And this is below my codes:
Does this work you think??
Please give me a suggest, because i cant test it ATM, since when i was going to test this with my bro, my GTA SA bro crashed.
thanks
I was going to make simple duel system. And below is my whole code for this case:
pawn Код:
public OnPlayerConnect(playerid)
{
Duel[playerid] = 0; //variable to check if the player already in duel
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
isDuel[i] = 0;
}
}
//isDuel is variable to checking if there are already player in server duelling
return 1;
}
pawn Код:
CMD:duel(playerid, params[])
{
new ID;
new str[128];
new Name[MAX_PLAYER_NAME];
new Name2[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
GetPlayerName(ID, Name2, sizeof(Name2));
if(sscanf(params,"u",ID))return SendClientMessage(playerid, COLOR_WHITE, "Usage /duel id");
if(Duel[playerid] == 1)return SendClientMessage(playerid, COLOR_WHITE, "You are already in duel");
if(!IsPlayerConnected(ID))return SendClientMessage(playerid, -1, "that player is not connected");
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(isDuel[i] == 1)return SendClientMessage(playerid, -1, "Duel already in progress");
}
}
format(str,sizeof(str), "%s(ID:%d) vs %s(ID:%d) has been started!",Name,playerid,Name2,ID);
SetPlayerPos(playerid, -2404.4795,-1623.3090,518.2908);
SetPlayerPos(ID, -2404.4795,-1623.3090,518.2908);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 24, cellmax);
GivePlayerWeapon(playerid, 27, cellmax);
ResetPlayerWeapons(ID);
GivePlayerWeapon(ID, 24, cellmax);
GivePlayerWeapon(ID, 27, cellmax);
new Float:health;
GetPlayerHealth(playerid, health);
if(Duel[playerid] == 1 && Duel[ID] == 1 && health== 0)
{
SpawnPlayer(ID);
SendClientMessage(ID, -1, "You Won");
SendClientMessage(playerid, -1, "You loose");
Duel[playerid] = 0;
Duel[ID] = 0;
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
isDuel[i] = 0;
}
}
}
Duel[playerid] = 1;
Duel[ID] = 1;
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
isDuel[i] = 1;
}
}
SendClientMessageToAll(COLOR_ORANGE, str);
return 1;
}
Please give me a suggest, because i cant test it ATM, since when i was going to test this with my bro, my GTA SA bro crashed.
thanks