Script does not work like it have to [ REP + ]
#1

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!
Reply
#2

did you try to put

PHP код:
    else if(Dueler[1] == playerid)
    {
        
SetPlayerPos(playerid1874.0762,-1744.3434,5206.0859);
         new 
string[128];
        
format(stringsizeof(string), "[ DUEL ] Player %s joined the duel, duel has started!",GetName(playerid));
          
SendClientMessageToAll(COLOR_REDstring);
        
TogglePlayerControllable(playerid1);
        
TogglePlayerControllable(Dueler[0], 1);
        
GameTextForPlayer(playerid"Duel started!"5001);
    } 
Reply
#3

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.
Reply
#4

Quote:
Originally Posted by _GHT_MarK445
Посмотреть сообщение
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
PHP код:
if(Dueler[1] == playerid
to
PHP код:
else if(Dueler[1] == playerid
Reply
#5

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;
}
Reply
#6

REP + please
Reply
#7

I repped you, can you guys please help me, with problem explained above?
Reply
#8

Quote:
Originally Posted by _GHT_MarK445
Посмотреть сообщение
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
Reply
#9

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;
}
Reply
#10

Quote:
Originally Posted by bigboy81
Посмотреть сообщение
REP + please
Are you serious?

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


Forum Jump:


Users browsing this thread: 1 Guest(s)