Variable Help
#1

Hi,

As I am scripting my custom Game-Mode, I'm experiencing a bit of difficulty. I am trying to make a system where if the player has already typed a command in, He can never type it in again.

What I mean by this is when a person types ("/startcareer") he will be taken to a tutorial which he must complete, After that, He is unable to use the command, It will send him a message saying, Tutorial already used or something.

I do have a bit of knowledge of variables however this one is a bit tricky. If anyone could help, I will appreciate it.
Reply
#2

Quote:
Originally Posted by McBan
Посмотреть сообщение
Hi,

As I am scripting my custom Game-Mode, I'm experiencing a bit of difficulty. I am trying to make a system where if the player has already typed a command in, He can never type it in again.

What I mean by this is when a person types ("/startcareer") he will be taken to a tutorial which he must complete, After that, He is unable to use the command, It will send him a message saying, Tutorial already used or something.

I do have a bit of knowledge of variables however this one is a bit tricky. If anyone could help, I will appreciate it.
hmm here is an easy idea just make a timer for the cmd means when he does the cmd the timer starts and he cant do the cmd again till the timer finishes
Reply
#3

Hmm, It would be more efficient if I did it the "real" way.
Reply
#4

Quote:
Originally Posted by McBan
Посмотреть сообщение
Hmm, It would be more efficient if I did it the "real" way.
okay another idea show me your cmd and the news for it and all ill do it with vars for u
Reply
#5

You could do this:
pawn Код:
new HasStartedC[MAX_PLAYERS];//global variable

CMD:startcareer(playerid, params[])
{
    if(HasStartedC[playerid] == 0)//Checks if player has not started a career yet.
    {
        //do some stuff
        HasStartedC[playerid] = 1;//Set the variable for the playerid to 1
    }
    else//If player already started a career
    {
        SendClientMessage(playerid, -1, "Tutorial already used or something");
    }
    return 1;
}
Reply
#6

I assume that the player can only use the command when he joins the server for the first time, right? If so refer to the code below, otherwise explain more about it, and how you would like it.

pawn Код:
new bool:TutorialPermission[MAX_PLAYERS] = false;

// OnPlayerRegister:
TotutialPermission[playerid] = true;

// Command "/startcareer":
if(TotutialPermission[playerid] == false) return SendClientMessage(playerid, 0xFFFFFFFF, "You can't use this command anymore.");
TotutialPermission[playerid] = false;
Reply
#7

Save the variable "HasStartedC" in the players user file
Reply
#8

Assign a variable to that command then when he used it increase the variable aka make it true. then make an (IF) statement which checks if that variable is 1/true if so then send him a message that he can't use this command again if 0/false then proceed with the CMD.
Reply
#9

You can either use OnPlayerCommandPerformed or you can use it incommand.

I'd imagine you'd only need to check whether he's registered and if he's already started a career, which could easily be saved in any SQL/INI system.


Process:

Check if player is registered & variable careermade is 0.
If it's 0, let them use the command.
If not, the don't.

The OnPLayerCommandPErformed way would be just to compare cmdtext[] with /startcareer, then just do the same process.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)