Variables..
#1

Hey guys, i have a little question :P

If i make a variable like:

pawn Код:
new Computer[MAX_PLAYERS];
Then is it possible to check if the player got a computer, or whatever is stored in the variable.
If yes, then give a example on how.
Reply
#2

better try this:

pawn Код:
new Computer[MAX_PLAYERS char];
you can use it using an if statement:
pawn Код:
if(Computer{playerid})
{
    SendClientMessage(playerid, ~1, "You have a computer.");
}
else
{
    SendClientMessage(playerid, ~1, "You don't have a computer, but you own one now.");
    Computer{playerid} = true;
}
//rest of code
Reply
#3

Is it just like IsPlayerAdmin, and such things?

pawn Код:
if(Computer(playerid)) return SendClientMessage(playerid, -1, "You dont got a computer");
Just like that?
Reply
#4

yes, but you should use in those brackets because of char { }, and add the ! in front of the variable to see if he didn't got one.

pawn Код:
if(!Computer{playerid}) return SendClientMessage(playerid, -1, "You dont got a computer");
Reply
#5

And then code under that, should be what will happen if he DO got a computer?
Reply
#6

yes, you understood
Reply
#7

yes, just add else {



}
Reply
#8

Quote:
Originally Posted by cruteX_modshop
Посмотреть сообщение
And then code under that, should be what will happen if he DO got a computer?
Operator '!' means not.

pawn Код:
if ( Computer{playerid} )
{
    // if player got computer do your code
}


if ( !Computer{playerid} )
{
    // if player DONT got computer do your code
}
Reply
#9

Yea, but do i have to do:

pawn Код:
if (!Computer{playerid} ) return SendClientMessage(playerid, -1, "You dont got a computer");

      else
      {
       if (Computer{playerid} )
       //my code here..
      }
Reply
#10

No, you just can simply do:

pawn Код:
if (!Computer{playerid} ) return SendClientMessage(playerid, -1, "You dont got a computer");
else
{
    SendClientMessage( playerid, -1, "You HAVE got a computer" );
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)