Variables.. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Variables.. (
/showthread.php?tid=300072)
Variables.. -
NessaHD - 28.11.2011
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.
Re: Variables.. -
fordawinzz - 28.11.2011
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
Re: Variables.. -
NessaHD - 28.11.2011
Is it just like IsPlayerAdmin, and such things?
pawn Код:
if(Computer(playerid)) return SendClientMessage(playerid, -1, "You dont got a computer");
Just like that?
Re: Variables.. -
fordawinzz - 28.11.2011
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");
Re: Variables.. -
NessaHD - 28.11.2011
And then code under that, should be what will happen if he DO got a computer?
Re: Variables.. -
fordawinzz - 28.11.2011
yes, you understood
Re: Variables.. -
System64 - 28.11.2011
yes, just add else {
}
Re: Variables.. -
SmiT - 28.11.2011
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
}
Re: Variables.. -
NessaHD - 28.11.2011
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..
}
Re: Variables.. -
SmiT - 28.11.2011
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" );
}