PDA

View Full Version : Script does not work like it have to [ REP + ]


_GHT_MarK445
06/03/2015, 01:46 PM
Hi guys,

i have a problem, i am solving this one over a week now, and me and my friend, just cant solve it and make it work, like it have to, so i am turning on you guys, to help me with this.

How it works now (UNCORRECT)

If the player writes /dueljoin it moves him, to the duel(SetPlayerPos), but the duel starts immediately.



How it have to work (CORRECT)

If the first dueler, join the duel, he should be frozen. And if the second dueler join in, it should start the duel.


------------------------------------------------

So guys, if you would be enable to get a soultion, how to fix it, what is wrong with it, i would really, really appreciate it, and off course REP+ you.

Command /dueljoin:

CMD:dueljoin(playerid, params[])
{
#pragma unused params
if(Duelers > 1) return SendClientMessage(playerid, COLOR_GREY, "[ CHYBA ] Duel is already full.");
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 0);
SetPlayerVirtualWorld(playerid, 1);
TogglePlayerControllable(playerid, 0);
if(Dueler[0] == INVALID_PLAYER_ID) Dueler[0] = playerid;
else if(Dueler[1] == INVALID_PLAYER_ID) Dueler[1] = playerid;
if(Dueler[0] == playerid)
{
SetPlayerPos(playerid, 1869.6478,-1748.4121,5206.0859);
new string[128];
format(string, sizeof(string), "[ DUEL ] Player %s joined the duel, type /dueljoin to join the duel and fight with him!",GetName(playerid));
SendClientMessageToAll(COLOR_RED, string);
}
if(Dueler[1] == playerid)
{
SetPlayerPos(playerid, 1874.0762,-1744.3434,5206.0859);
new string[128];
format(string, sizeof(string), "[ DUEL ] Player %s joined the duel, duel has started!",GetName(playerid));
SendClientMessageToAll(COLOR_RED, string);
TogglePlayerControllable(playerid, 1);
TogglePlayerControllable(Dueler[0], 1);
GameTextForPlayer(playerid, "Duel started!", 500, 1);
}
return 1;
}


For any help i would be really really HAPPY!

bigboy81
06/03/2015, 01:51 PM
did you try to put

else if(Dueler[1] == playerid)
{
SetPlayerPos(playerid, 1874.0762,-1744.3434,5206.0859);
new string[128];
format(string, sizeof(string), "[ DUEL ] Player %s joined the duel, duel has started!",GetName(playerid));
SendClientMessageToAll(COLOR_RED, string);
TogglePlayerControllable(playerid, 1);
TogglePlayerControllable(Dueler[0], 1);
GameTextForPlayer(playerid, "Duel started!", 500, 1);
}

_GHT_MarK445
06/03/2015, 01:57 PM
Could you please explain me, what did it changed? I mean, when i want to change something, i also want to know why, and what was changed. Thanks.

bigboy81
06/03/2015, 02:12 PM
Could you please explain me, what did it changed? I mean, when i want to change something, i also want to know why, and what was changed. Thanks.

I changed only if(Dueler[1] == playerid) to else if(Dueler[1] == playerid)

_GHT_MarK445
06/03/2015, 02:24 PM
Thx it worked.

But i added if, the player is already in the duel, he wont be enable to join again.

But, even if the player is not in the duel, it writes him message, that he is.. thx.

dcmd_dueljoin(playerid, params[])
{
#pragma unused params
if(Dueler[0] == playerid) return SendClientMessage(playerid, F_SEDA, "[ CHYBA ] Už si v dueli.");
else if(Dueler[1] == playerid) return SendClientMessage(playerid, F_SEDA, "[ CHYBA ] Už si v dueli.");
if(Duelers > 1) return SendClientMessage(playerid, F_SEDA, "[ CHYBA ] Duel je už plný.");
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 0);
SetPlayerVirtualWorld(playerid, 1);
TogglePlayerControllable(playerid, 0);
if(Dueler[0] == INVALID_PLAYER_ID) Dueler[0] = playerid;
else if(Dueler[1] == INVALID_PLAYER_ID) Dueler[1] = playerid;
if(Dueler[0] == playerid)
{
SetPlayerPos(playerid, 1869.6478,-1748.4121,5206.0859);
new string[128];
format(string, sizeof(string), "[ DUEL ] Hráč %s sa pripojil do duelu, napíš /dueljoin pre pripojenie k nemu..",GetName(playerid));
SendClientMessageToAll(F_JAILBREAKOVA, string);
}
else if(Dueler[1] == playerid)
{
SetPlayerPos(playerid, 1874.0762,-1744.3434,5206.0859);
new string[128];
format(string, sizeof(string), "[ DUEL ] Hráč %s sa pripojil do duelu, duel sa začal.",GetName(playerid));
SendClientMessageToAll(F_JAILBREAKOVA, string);
TogglePlayerControllable(playerid, 1);
TogglePlayerControllable(Dueler[0], 1);
GameTextForPlayer(playerid, "duel sa zacal, do seba!", 500, 1);
}
return 1;
}

bigboy81
06/03/2015, 04:34 PM
REP + please

_GHT_MarK445
06/03/2015, 09:01 PM
I repped you, can you guys please help me, with problem explained above?

bigboy81
07/03/2015, 12:52 AM
I repped you, can you guys please help me, with problem explained above?

No you are not because i have 2 reputation before i help you

X337
07/03/2015, 03:03 AM
What is reputation for? :-/
You can put this in OnPlayerDeath, so if the player in duel dead, he/she can join the duel again.

public OnPlayerDeath(playerid, killerid, reason)
{
if(Dueler[0] == playerid)
Dueler[0] = INVALID_PLAYER_ID;
else if(Dueler[1] == playerid)
Dueler[1] = INVALID_PLAYER_ID;

return 1;
}

maramizo
07/03/2015, 03:06 AM
REP + please
Are you serious?

Anyway, @OT, can you show me the declarations for "Dueler" and "Duelers"?