SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 02/01/2020, 07:00 AM   #1
Filbert
Huge Clucker
 
Join Date: May 2016
Posts: 204
Reputation: 1
Default duel system

I'm making a duel system and having a problem with the BET money.
If i use :
PHP Code:
new Bet
PHP Code:
new targetduelbet;
    if(
sscanf(params"ui"targetduelbet)) return SendClientMessage(playeridred,"USAGE: /duel [PlayerID] [bet]"); 
PHP Code:
Bet duelbet
As far as i know, if there are 2 or more duels started at the same time, those bets will "crash".
I mean, the first bet will affect the second bet and so on..

I have solved a similar problem in my duel system, like the :
PHP Code:
SetPlayerVirtualWorld(dueler1dueler1 10);
SetPlayerVirtualWorld(dueler2dueler1 10); 
So if there are 2 or more duels, they wont duel in a same world, which means the server could has an unlimited duels started in a same time.

But, idk about this BET. How to make it?
Filbert is offline   Reply With Quote
Old 02/01/2020, 08:11 AM   #2
Vizi10
Huge Clucker
 
Join Date: May 2017
Location: Iran
Posts: 286
Reputation: 8
Default Re: duel system

Send the all cmd duel code.
Vizi10 is offline   Reply With Quote
Old 02/01/2020, 08:20 AM   #3
Filbert
Huge Clucker
 
Join Date: May 2016
Posts: 204
Reputation: 1
Default Re: duel system

Quote:
Originally Posted by Vizi10 View Post
Send the all cmd duel code.
That's not a code error.
I just want some tips to make the BETs of every duels dont affect each other..
Filbert is offline   Reply With Quote
Old 02/01/2020, 08:37 AM   #4
Vizi10
Huge Clucker
 
Join Date: May 2017
Location: Iran
Posts: 286
Reputation: 8
Default Re: duel system

So..
pawn Code:
#define MAX_BETS 1000

new Bet[MAX_BETS],
    LastBetID = 0,
    Dueler[2][MAX_BETS];

//duel cmd:
LastBetID++;
Bet[LastBetID] = duelbet;
Dueler[0][LastBetID] = playerid;
Dueler[1][LastBetID] = target;
Vizi10 is offline   Reply With Quote
Old 02/01/2020, 08:40 AM   #5
ShadowMortar
Big Clucker
 
ShadowMortar's Avatar
 
Join Date: Jul 2016
Location: Croatia
Posts: 146
Reputation: 29
Default Re: duel system

You could do it this way, make a global variable and assign it, :
( NOT TESTED )
PHP Code:
new DuelBetMAX_PLAYERS ] = { 0, ... }, bool:InDuelMAX_PLAYERS ] = { false, ... }, OfferedDuelByMAX_PLAYERS ] = { INVALID_PLAYER_ID, ... };
CMD:duelplayeridparams[ ] ) {
    new 
giveplayeridbet;
    if( 
sscanfparams"ud"giveplayeridbet ) ) SendClientMessageplayerid, -1"Usage: /duel [Opponent ID] [Bet]" );
    else if( 
GetPlayerMoneyplayerid ) < bet SendClientMessageplayerid, -1"You're poor." );
    else {
        
OfferedDuelBygiveplayerid ] = playerid;
        
OfferedDuelByplayerid ] = giveplayerid;
        
DuelBetplayerid ] = bet;
        
SendClientMessageExplayerid, -1"You've challenged %s, they've to type /acceptduel."PlayerOOCNamegiveplayerid ) );
        
SendClientMessageExgiveplayerid, -1"You've been challenged by %s, type /acceptduel to accept it."PlayerOOCNameplayerid ) );
    }
    return ( 
true );
}
CMD:acceptduelplayerid ) {
    new 
id OfferedDuelByplayerid ];
    if( 
id == INVALID_PLAYER_ID SendClientMessageplayerid, -1"You weren't challenged." );
    else {
        
SetPlayerPosplayerid00);
        
SetPlayerVirtualWorldplayerid);
        
SetPlayerPosid00);
        
SetPlayerVirtualWorldid);
        
DuelBetplayerid ] = DuelBetid ];
        
InDuelplayerid ] = true;
        
InDuelid ] = true;
    }
    return ( 
true );
}
public 
OnPlayerDeathplayerid ) {
    if( 
InDuelplayerid ] ) {
        new 
id OfferedDuelByplayerid ];
        
GivePlayerMoneyplayerid, -DuelBetplayerid ] );
        
GivePlayerMoneyidDuelBetplayerid ] );
        
SendClientMessageExplayerid, -1"%s has killed you hence you lost $%d"PlayerOOCNameid ), DuelBetplayerid ] );
        
SendClientMessageExid, -1"You killed %s and won $%d."PlayerOOCNameplayerid ), DuelBetplayerid ] );
        
DuelBetid ] = 0;
        
InDuelid ] = false;
        
OfferedDuelByid ] = INVALID_PLAYER_ID;
        
DuelBetplayerid ] = 0;
        
InDuelplayerid ] = false;
        
OfferedDuelByplayerid ] = INVALID_PLAYER_ID;
    } 
    return ( 
true );
}
public 
OnPlayerDisconnectplayeridreason ) {
    if( 
InDuelplayerid ] ) {
        new 
id OfferedDuelByplayerid ];
        
SendClientMessageExid, -1"Your opponent %s has disconnected from the server."PlayerOOCNameplayerid ) );
        
DuelBetid ] = 0;
        
InDuelid ] = false;
        
OfferedDuelByid ] = INVALID_PLAYER_ID;
    }
    
DuelBetplayerid ] = 0;
    
InDuelplayerid ] = false;
    
OfferedDuelByplayerid ] = INVALID_PLAYER_ID;
    return ( 
true );

__________________
Quote:
Originally Posted by CheezIt View Post
Follow your heart and own style.
Feel free to PM me if you need help.
ShadowMortar is offline   Reply With Quote
Old 02/01/2020, 09:06 AM   #6
Filbert
Huge Clucker
 
Join Date: May 2016
Posts: 204
Reputation: 1
Default Re: duel system

Quote:
Originally Posted by ShadowMortar View Post
You could do it this way, make a global variable and assign it, :
( NOT TESTED )
PHP Code:
new DuelBetMAX_PLAYERS ] = { 0, ... }, bool:InDuelMAX_PLAYERS ] = { false, ... }, OfferedDuelByMAX_PLAYERS ] = { INVALID_PLAYER_ID, ... };
CMD:duelplayeridparams[ ] ) {
    new 
giveplayeridbet;
    if( 
sscanfparams"ud"giveplayeridbet ) ) SendClientMessageplayerid, -1"Usage: /duel [Opponent ID] [Bet]" );
    else if( 
GetPlayerMoneyplayerid ) < bet SendClientMessageplayerid, -1"You're poor." );
    else {
        
OfferedDuelBygiveplayerid ] = playerid;
        
OfferedDuelByplayerid ] = giveplayerid;
        
DuelBetplayerid ] = bet;
        
SendClientMessageExplayerid, -1"You've challenged %s, they've to type /acceptduel."PlayerOOCNamegiveplayerid ) );
        
SendClientMessageExgiveplayerid, -1"You've been challenged by %s, type /acceptduel to accept it."PlayerOOCNameplayerid ) );
    }
    return ( 
true );
}
CMD:acceptduelplayerid ) {
    new 
id OfferedDuelByplayerid ];
    if( 
id == INVALID_PLAYER_ID SendClientMessageplayerid, -1"You weren't challenged." );
    else {
        
SetPlayerPosplayerid00);
        
SetPlayerVirtualWorldplayerid);
        
SetPlayerPosid00);
        
SetPlayerVirtualWorldid);
        
DuelBetplayerid ] = DuelBetid ];
        
InDuelplayerid ] = true;
        
InDuelid ] = true;
    }
    return ( 
true );
}
public 
OnPlayerDeathplayerid ) {
    if( 
InDuelplayerid ] ) {
        new 
id OfferedDuelByplayerid ];
        
GivePlayerMoneyplayerid, -DuelBetplayerid ] );
        
GivePlayerMoneyidDuelBetplayerid ] );
        
SendClientMessageExplayerid, -1"%s has killed you hence you lost $%d"PlayerOOCNameid ), DuelBetplayerid ] );
        
SendClientMessageExid, -1"You killed %s and won $%d."PlayerOOCNameplayerid ), DuelBetplayerid ] );
        
DuelBetid ] = 0;
        
InDuelid ] = false;
        
OfferedDuelByid ] = INVALID_PLAYER_ID;
        
DuelBetplayerid ] = 0;
        
InDuelplayerid ] = false;
        
OfferedDuelByplayerid ] = INVALID_PLAYER_ID;
    } 
    return ( 
true );
}
public 
OnPlayerDisconnectplayeridreason ) {
    if( 
InDuelplayerid ] ) {
        new 
id OfferedDuelByplayerid ];
        
SendClientMessageExid, -1"Your opponent %s has disconnected from the server."PlayerOOCNameplayerid ) );
        
DuelBetid ] = 0;
        
InDuelid ] = false;
        
OfferedDuelByid ] = INVALID_PLAYER_ID;
    }
    
DuelBetplayerid ] = 0;
    
InDuelplayerid ] = false;
    
OfferedDuelByplayerid ] = INVALID_PLAYER_ID;
    return ( 
true );

I understand, thanks man. REP+
Filbert is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Duel System DKN | /duel [playerid] ipsBruno Filterscripts 10 22/05/2018 02:55 AM
Need help in duel system ! VenomMancer Scripting Help 6 04/03/2015 04:02 PM
Duel system YanLanger Scripting Help 2 03/07/2014 09:15 AM
Need help with duel system [/duel] admantis Scripting Help 5 12/11/2011 09:10 AM
Duel System [EnergY] Help Archive 1 21/03/2010 05:12 PM


All times are GMT. The time now is 11:56 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.