Scripting issue
#1

(I'm a Beginner, so I might say stupid things, I started learning pawno 1 day ago)
I made a /whereismech command that creates a checkpoint at the mechanic place, I also added a boolean(false) that gets a (true) after using the checkpoint command, so the player will need to /deletecheckpoint to have another
Everything works fine, that's what I thought in the beginning. It does actually but only if there's 1 player in the server, when there are 2 players if one of them uses /whereismech , a checkpoint will appear, and the boolean will change to (true) so he won't be able to /whereismech again before using /deletecheckpoint or touching the checkpoint, the second player also can't use /whereismech since the boolean contains true already , because the first player used the /whereismech command: I wish you get it .
Code
pawn Код:
new bool:Bo=false;

pawn Код:
if (strcmp(cmdtext, "/whereismech", true) == 0)
    {
        if (Bo == true) return SendClientMessage(playerid, 0xFF0000AA, "You already have an active Checkpoint, please use /deletecheckpoint to have another one");
        else
        {
        if (!IsPlayerInRangeOfPoint(playerid, 5, 1607.2327, -1841.8683, 13.5116))
        {
            SetPlayerCheckpoint(playerid, 1607.2327, -1841.8683, 13.5116, 3);
            SendClientMessage (playerid, 0xFF0000AA, "Go to the checkpoint and /repair there");
            Bo=true;
            return 1;
        }
        else
        {
        SendClientMessage(playerid, 0xFF0000AA, "You are already in the mechanic place, use /repair, this will cost you 5000$");
        return 1;
        }
        }
       
    }

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
DisablePlayerCheckpoint(playerid);
PlayerPlaySound(playerid, 1139, 0.0, 0.0, 0.0);
Bo=false;
return 1;
}
Any Idea? How Can I fix it so the boolean doesn't change for everyone, only for the player who has used the command
Reply
#2

Quote:
Originally Posted by Sarra
Посмотреть сообщение
(I'm a Beginner, so I might say stupid things, I started learning pawno 1 day ago)
I made a /whereismech command that creates a checkpoint at the mechanic place, I also added a boolean(false) that gets a (true) after using the checkpoint command, so the player will need to /deletecheckpoint to have another
Everything works fine, that's what I thought in the beginning. It does actually but only if there's 1 player in the server, when there are 2 players if one of them uses /whereismech , a checkpoint will appear, and the boolean will change to (true) so he won't be able to /whereismech again before using /deletecheckpoint or touching the checkpoint, the second player also can't use /whereismech since the boolean contains true already , because the first player used the /whereismech command: I wish you get the point guys.
Code
pawn Код:
new bool:Bo=false;

pawn Код:
if (strcmp(cmdtext, "/whereismech", true) == 0)
    {
        if (Bo == true) return SendClientMessage(playerid, 0xFF0000AA, "You already have an active Checkpoint, please use /deletecheckpoint to have another one");
        else
        {
        if (!IsPlayerInRangeOfPoint(playerid, 5, 1607.2327, -1841.8683, 13.5116))
        {
            SetPlayerCheckpoint(playerid, 1607.2327, -1841.8683, 13.5116, 3);
            SendClientMessage (playerid, 0xFF0000AA, "Go to the checkpoint and /repair there");
            Bo=true;
            return 1;
        }
        else
        {
        SendClientMessage(playerid, 0xFF0000AA, "You are already in the mechanic place, use /repair, this will cost you 5000$");
        return 1;
        }
        }
       
    }

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
DisablePlayerCheckpoint(playerid);
PlayerPlaySound(playerid, 1139, 0.0, 0.0, 0.0);
Bo=false;
return 1;
}
Any Idea? How Can I fix it so the boolean doesn't change for everyone, only for the player who has used the command
hmm i dont get the problem but anyway put under OnPlayerConnect Bo = 0; this will set the Boolean to false when a player connects and go to each cmd u made that makes a checkpoint and put the bo get me?
Edit: Where are you from?
Reply
#3

Alright let me explain,
Now there are 2 players in the server, A and B, Bo contains false,
player A uses /whereismech a checkpoint appears and Bo contains true
Player B uses whereismech a message appears "You already have an active Checkpoint, please use /deletecheckpoint to have another one" since Bo contains true,
Bo have to get back to false, so Player B can use /whereismech
I want, when the player uses /whereismech, the boolean value goes to true for the player who used the command only, idk if this is possible
Reply
#4

Quote:
Originally Posted by Sarra
Посмотреть сообщение
Alright let me explain,
Now there are 2 players in the server, A and B, Bo contains false,
player A uses /whereismech a checkpoint appears and Bo contains true
Player B uses whereismech a message appears "You already have an active Checkpoint, please use /deletecheckpoint to have another one" since Bo contains true,
Bo have to get back to false, so Player B can use /whereismech
I want, when the player uses /whereismech, the boolean value goes to true for the player who used the command only, idk if this is possible
ahh now i get it xD then try sth its not tested but u dont have anything to lose just replace
new bool:bo=0; to be
new bool:Bo[MAX_PLAYERS] = 0;
and each time u use the bo make it bo[playerid] get me?
Reply
#5

you need to use a variable for each player

like

pawn Код:
new Bo[MAX_PLAYERS];
then onplayerconnect

pawn Код:
Bo[playerid] = 0;
after this

pawn Код:
if (strcmp(cmdtext, "/whereismech", true) == 0)
{
        if (Bo[playerid] == 1) return SendClientMessage(playerid, 0xFF0000AA, "You already have an active Checkpoint, please use /deletecheckpoint to have another one");
        else if (!IsPlayerInRangeOfPoint(playerid, 5, 1607.2327, -1841.8683, 13.5116))
        {
                SetPlayerCheckpoint(playerid, 1607.2327, -1841.8683, 13.5116, 3);
                SendClientMessage (playerid, 0xFF0000AA, "Go to the checkpoint and /repair there");
                Bo[playerid]=1;
                return 1;
        }
        else
        {
            SendClientMessage(playerid, 0xFF0000AA, "You are already in the mechanic place, use /repair, this will cost you 5000$");
            return 1;
        }
   
}
   
public OnPlayerEnterCheckpoint(playerid)
{
DisablePlayerCheckpoint(playerid);
PlayerPlaySound(playerid, 1139, 0.0, 0.0, 0.0);
Bo[playerid]=0;
return 1;
}
Reply
#6

Change
pawn Код:
new bool:Bo=false;
to
pawn Код:
new bool:Bo[MAX_PLAYERS]=false;
then change every Bo to Bo[playerid], like
pawn Код:
if(Bo == true)
to
pawn Код:
if(Bo[playerid] == true)
etc..
Reply
#7

Alright guys you all had the same answer thanks I get it now and I'll rep you all, that was really helpful, I just learned a new thing
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)