Little help on this
#1

i was trying to make duel 1v1/2v2 and so on now the issue is that i dont really know how to make these things.
player writes /startduel 1v1 then send him message Player 1 Player 2 and Prize, he sets them and after that the function StartDuel will get used can someone help me please.

Here's script
https://pastebin.com/qF0sWZk3
Reply
#2

Pastebin link doesn't work. Fixed?
Reply
#3

Okay, I'm gonna try to tell you what you need. I'll try to make you script the whole thing. First, open up a notepad or your text editor or even a notebook and start writing down what all do you need. Think of all the things you would want in a duel system, eg:- 1v1 system, 2v2 system, duel accept, duel reject. What you do next is what sets people apart from Good programmers and bad ones. They try to look at the problem from a different angle and they try to solve this. I can't refer to your script cuz' the link is broken!

So obviously need a /startduel command. I'll be using ZCMD in this example (Hope you know what ZCMD is.)

So it would start something like this.

PHP код:
CMD:startduel(playeridparams[])
{
    
// Here will be our code.
    
return 1;

Next comes the part where you actually use your ideas and think. Do I want players to use this command if they are jailed? Do I want them to Use this command if they haven't spawned? Then you start adding the stuffs where the command wouldn't work.

PHP код:
CMD:startduel(playeridparams[])
{
    
//JUST AN EXAMPLE CODE!!!!!!!
    
if(!HasPlayerSpawned(playerid)) return SendClientMessage(playeridcolor"You haven't spawned");
    if(!
IsPlayerJailed(playerid)) return SendClientMessage(playeridcolor"You are jailed");
    return 
1;

One of the problems you face when dealing with systems like this is if the player is already in a duel, Then he can't be in a duel again. So we need to create a variable to see if the player is in a duel, and also set it a value when the player joins because obviously he won't be in a duel when He joins. So:

PHP код:
new Dueling[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
    
Dueling[playerid] = 0;
    return 
1;
}
CMD:startduel(playeridparams[])
{
    return 
1;

Now we can check if the player is in a duel by doing this:

PHP код:
new Dueling[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
    
Dueling[playerid] = 0;
    return 
1;
}
CMD:startduel(playeridparams[])
{
    if(
Dueling[playerid]) return SendClientMessage(playeridcolor"You are already in a duel");
    return 
1;

See? You've completed 10% of the script in less thatn 5 mins. Now cross out this error in your Book/Notepad/Text Editor. Now think of the next problem. We need the command to be able to pass parameters. So we use sscanf. WE also check if the target player is in a duel or not

PHP код:
new Dueling[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
    
Dueling[playerid] = 0;
    return 
1;
}
CMD:startduel(playeridparams[])
{
    if(
Dueling[playerid]) return SendClientMessage(playeridcolor"You are already in a duel");
    new 
targetid;
    if(
sscanf(params,"u"targetid)) return SendClientMessage(playeridcolor,"Syntax error.Correct usage: /startduel [PlayerID]");
    if(
Dueling[targetid]) return SendClientMessage(playeridcolor"That player is already in a duel");
    
    
//rest of the code
    
return 1;

Now all you have to do is set both of there Dueling variables to 1, Give them a weapon, Teleport them to an arena, add a countdown and you are done!

This is the Scripting Help section, Not the Script request system. I've tried my best to tell you how the system works. And one more thing, next time please SEARCH. You can find a lot of simple script on duel systems. Try to go through them. Understand what each line does. If you really love programming and making scripts, You will put the time and effort into each and every thing you make. And trust me, There is a satisfaction you get when you make something. And that is really priceless! Just try to learn. Have a Nice day/night.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)