[Help]: Duel System.
#1

Hello!

I want to make a duel system and I have a /duel command, but I don't know how to make /accept command...

Duel Command:

PHP код:
CMD:duel(playeridparams[])
{
    new 
targetid;
    new 
weaponid;
    new 
ammo;
    new 
string[300];
    if(!
IsPlayerConnected(targetid)) return SendClientMessage(playeridCOLOR_RED"ERROR: This Player is Not Connected!");
    if(
sscanf(params"uii"targetidweaponidammo)) return SendClientMessage(playeridCOLOR_ORANGE"Usage: /duel [playerid] [weaponid] [amount]");
    
format(stringsizeof(string), "[DUEL]: %s Want a Duel With You. Type /accept, To Start The Duel."GetName(playerid));
    
SendClientMessage(targetidCOLOR_LIGHTREDstring);
    
SetPlayerPos(playerid, -1401.9368,1266.0421,1039.8672);
    
SetPlayerPos(targetid, -1397.5286,1225.9540,1039.8741);
    
ResetPlayerWeapons(targetid);
    
ResetPlayerWeapons(playerid);
    
GivePlayerWeapon(playeridweaponidammo);
    
GivePlayerWeapon(targetidweaponidammo);
    
GameTextForPlayer(targetid"~b~GO GO GO!",3000,3);
    
GameTextForPlayer(playerid"~b~GO GO GO!",3000,3);
    return 
1;

Thank you for your help
Reply
#2

Anyone?
Reply
#3

Use this global variable: new DuelAccept[MAX_PLAYERS]; turn it 0-1 and combine it with ifs.
Reply
#4

Here you go

pawn Код:
Put this on top of your script
new duelinvite[playerid] = 999;
new duelid[playerid] = 999;
new duelweaponid[playerid] = 999;
new duelweaponammo[playerid] = 0;

under OnPlayerConnect
duelweaponid[playerid] = 999;
duelweaponammo = 0;
duelid[playerid] = 999;
duelinvite[playerid] = 999;


CMD:duel(playerid, params[])
{
    new targetid;
    new weaponid;
    new ammo;
    new string[300];
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "ERROR: This Player is Not Connected!");
    if(sscanf(params, "uii", targetid, weaponid, ammo)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /duel [playerid] [weaponid] [amount]");
    format(string, sizeof(string), "[DUEL]: %s Want a Duel With You. Type /accept, To Start The Duel.", GetName(playerid));
    SendClientMessage(targetid, COLOR_LIGHTRED, string);
    duelinvite[playerid] = 1;
    duelid[playerid] = targetid;
    duelweaponid[playerid] = weaponid;
    duelweaponammo[playerid] = ammo;

    return 1;
}
CMD:accept(playerid, params[])
{
    if(duelinvited[playerid] < 999)
    {
        if(IsPlayerConnected(duelinvite[playerid]))
        {
            SetPlayerPos(playerid, -1401.9368,1266.0421,1039.8672);
            SetPlayerPos(duelid[playerid], -1397.5286,1225.9540,1039.8741);
            ResetPlayerWeapons(duelid[playerid]);
            ResetPlayerWeapons(playerid);
            GivePlayerWeapon(playerid, duelweaponid, duelweaponammo);
            GivePlayerWeapon(duelid[playerid], duelweaponid, duelweaponammo);
            GameTextForPlayer(duelid[playerid], "~b~GO GO GO!",3000,3);
            GameTextForPlayer(playerid, "~b~GO GO GO!",3000,3);
            duelinvite[playerid] = 999;
            duelid[playerid] = 999;
            duelweaponid[playerid] = 999
            duelweaponammo[playerid] = 0;
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "   The player invited  you a duel has disconnected!");
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_GREY, " Nobody Offered you a duel");
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by HurtLocker
Посмотреть сообщение
Use this global variable: new DuelAccept[MAX_PLAYERS]; turn it 0-1 and combine it with ifs.
Ok, I tried, but I did wrong...Anyway thanks.
Reply
#6

Quote:
Originally Posted by ToiletDuck
Посмотреть сообщение
Here you go

pawn Код:
Put this on top of your script
new duelinvite[playerid] = 999;
new duelid[playerid] = 999;
new duelweaponid[playerid] = 999;
new duelweaponammo[playerid] = 0;

under OnPlayerConnect
duelweaponid[playerid] = 999;
duelweaponammo = 0;
duelid[playerid] = 999;
duelinvite[playerid] = 999;


CMD:duel(playerid, params[])
{
    new targetid;
    new weaponid;
    new ammo;
    new string[300];
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "ERROR: This Player is Not Connected!");
    if(sscanf(params, "uii", targetid, weaponid, ammo)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /duel [playerid] [weaponid] [amount]");
    format(string, sizeof(string), "[DUEL]: %s Want a Duel With You. Type /accept, To Start The Duel.", GetName(playerid));
    SendClientMessage(targetid, COLOR_LIGHTRED, string);
    duelinvite[playerid] = 1;
    duelid[playerid] = targetid;
    duelweaponid[playerid] = weaponid;
    duelweaponammo[playerid] = ammo;

    return 1;
}
CMD:accept(playerid, params[])
{
    if(duelinvited[playerid] < 999)
    {
        if(IsPlayerConnected(duelinvite[playerid]))
        {
            SetPlayerPos(playerid, -1401.9368,1266.0421,1039.8672);
            SetPlayerPos(duelid[playerid], -1397.5286,1225.9540,1039.8741);
            ResetPlayerWeapons(duelid[playerid]);
            ResetPlayerWeapons(playerid);
            GivePlayerWeapon(playerid, duelweaponid, duelweaponammo);
            GivePlayerWeapon(duelid[playerid], duelweaponid, duelweaponammo);
            GameTextForPlayer(duelid[playerid], "~b~GO GO GO!",3000,3);
            GameTextForPlayer(playerid, "~b~GO GO GO!",3000,3);
            duelinvite[playerid] = 999;
            duelid[playerid] = 999;
            duelweaponid[playerid] = 999
            duelweaponammo[playerid] = 0;
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "   The player invited  you a duel has disconnected!");
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_GREY, " Nobody Offered you a duel");
    }
    return 1;
}
I get this errors:

PHP код:
C:\DOCUME~1\Tadej\Desktop\SA-MPS~1\GAMEMO~1\New.pwn(2150) : error 035argument type mismatch (argument 2)
C:\DOCUME~1\Tadej\Desktop\SA-MPS~1\GAMEMO~1\New.pwn(2151) : error 035argument type mismatch (argument 2)
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
2 Errors

In this lines:

PHP код:
            GivePlayerWeapon(playeridduelweaponidduelweaponammo);
            
GivePlayerWeapon(duelid[playerid], duelweaponidduelweaponammo); 
Reply
#7

Lol i forgot to put [playerid] here
pawn Код:
GivePlayerWeapon(playerid, duelweaponid[playerid], duelweaponammo[playerid]);
GivePlayerWeapon(duelid[playerid], duelweaponid[playerid], duelweaponammo[playerid]);
Reply
#8

Quote:
Originally Posted by ToiletDuck
Посмотреть сообщение
Lol i forgot to put [playerid] here
pawn Код:
GivePlayerWeapon(playerid, duelweaponid[playerid], duelweaponammo[playerid]);
GivePlayerWeapon(duelid[playerid], duelweaponid[playerid], duelweaponammo[playerid]);
Thanks rep+
Reply
#9

Quote:
Originally Posted by Areax
Посмотреть сообщение
Thanks rep+
Welcome feel free to post help in this section, but btw im sorry i didn't explain what i did there ..

i dont know how to explain LoL
Reply
#10

Quote:
Originally Posted by ToiletDuck
Посмотреть сообщение
Welcome feel free to post help in this section, but btw im sorry i didn't explain what i did there ..

i dont know how to explain LoL
No problem Keep up the good work bro
Reply
#11

thx for helping me too
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)