SA-MP Forums Archive
Need help in duel system ! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need help in duel system ! (/showthread.php?tid=566214)



Need help in duel system ! - VenomMancer - 04.03.2015

I have problem, when i am inviting player for duel, invitation message not showing to his!

see my script:

pawn Код:
CMD:duel(playerid,params[])
{
    new target;
    if(pInfo[playerid][Minigame] == 1) return sMess(playerid,4);
    if(pInfo[playerid][Dinviter] != -1) return SendClientMessage(playerid,Red,"** You already have an invitation from player!");
    if(sscanf(params,"u",target)) return SendClientMessage(playerid,-1,"**Usage: /duel <playerid>");
    if(pInfo[target][Dinviter] != -1) return SendClientMessage(playerid,Red,"** Target have an invitation from player!");
    if(pInfo[target][InDuel] == 1) return SendClientMessage(playerid,Red,"** Target already in duel!");
    if(pInfo[playerid][InDuel] == 1) return SendClientMessage(playerid,Red,"** You are already in duel!");

    pInfo[playerid][Dinviter] = target;
   
    ShowPlayerDialog(playerid, DIALOG_DUEL, DIALOG_STYLE_LIST,"Select duel wepaon", "Sawn-off\nDeagle\nUzi", "Ok", "Back");
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    // duel
    if(dialogid == DIALOG_DUEL && response)
    {
            switch(dialogid)
            {
                case 0:
                {
                    new ms[500];
                    new target = pInfo[playerid][Dinviter];
                    // target = player id invited for duel!
                    // playerid = inviter

                    format(ms,500,"{808080}["WI"DUEL-INVITE{808080}] : Player %s is inviting you for duel Sawn-Off!",GetName(playerid));
                    SendClientMessage(target,-1,ms); // This message for player invite for duel!
                    SendClientMessage(target,-1,"==>> Type /yes if you want to duel!"); // This message for player invite for duel!
                    SendClientMessage(playerid,-1,"** Please wait for target accepting your request!"); // This message for inviter!
                    pInfo[target][Dinviter] = playerid;
                    pInfo[target][DuelType] = 1;
                    pInfo[playerid][DuelType] = 1;
                    SetTimerEx("ResetD",10000,0,"dd",pInfo[playerid][Dinviter],playerid);
                }
                case 1:
                {
                   
               
                }
                case 2:
                {
                   
                   
                }
            }
           
            if(!response)
            {
                pInfo[playerid][Dinviter] = -1;
            }
    }
    return 1;
}
Whats wrong ?

Sorry for my bad english


Re: Need help in duel system ! - wooolly - 04.03.2015

Instead of
Quote:

if(sscanf(params,"u",target)) return SendClientMessage(playerid,-1,"**Usage: /duel <playerid>");

try
Quote:

target = strval(params);

or something like that. Strval should work fine for getting the id from the string

Add some debugging code like printf(target); etc, to see what the value of the variable is when you are using it in the SendClientMessage. Printing variables always helps to find problems.

I haven't tested so I don't know if that is the problem, but I have never used the "u" character before in sscanf, so I just assume its something to do with that, but maybe not. I cant see any other problems as such.


Re: Need help in duel system ! - VenomMancer - 04.03.2015

i will test bro


Re: Need help in duel system ! - VenomMancer - 04.03.2015

still not worked !
anyone ?


Re: Need help in duel system ! - CalvinC - 04.03.2015

Why are you using both an if and a switch to check the dialogid?


Re: Need help in duel system ! - X337 - 04.03.2015

Код:
switch(dialogid)
to:
Код:
switch(listitem)



Re: Need help in duel system ! - VenomMancer - 04.03.2015

OMG !!!
my fault..
Sorry +rep