PDA

View Full Version : Little help on this


LazzyBoy
11/04/2017, 08:59 PM
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

xCrazyMonkey
11/04/2017, 11:10 PM
Pastebin link doesn't work. Fixed?

DarkSkull
12/04/2017, 01:56 AM
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.

CMD:startduel(playerid, params[])
{
// 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.

CMD:startduel(playerid, params[])
{
//JUST AN EXAMPLE CODE!!!!!!!
if(!HasPlayerSpawned(playerid)) return SendClientMessage(playerid, color, "You haven't spawned");
if(!IsPlayerJailed(playerid)) return SendClientMessage(playerid, color, "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:

new Dueling[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
Dueling[playerid] = 0;
return 1;
}

CMD:startduel(playerid, params[])
{
return 1;
}

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

new Dueling[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
Dueling[playerid] = 0;
return 1;
}

CMD:startduel(playerid, params[])
{
if(Dueling[playerid]) return SendClientMessage(playerid, color, "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

new Dueling[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
Dueling[playerid] = 0;
return 1;
}

CMD:startduel(playerid, params[])
{
if(Dueling[playerid]) return SendClientMessage(playerid, color, "You are already in a duel");
new targetid;
if(sscanf(params,"u", targetid)) return SendClientMessage(playerid, color,"Syntax error.Correct usage: /startduel [PlayerID]");
if(Dueling[targetid]) return SendClientMessage(playerid, color, "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.