I have a question.
#1

I would like to know how I can do so that only "VIP" players can access this script command.
https://sampforum.blast.hk/showthread.php?tid=501924

Type only who is VIP will be able to use the command and be able to use the objects.
Reply
#2

Quote:
Originally Posted by murilo2929
Посмотреть сообщение
I would like to know how I can do so that only "VIP" players can access this script command.
https://sampforum.blast.hk/showthread.php?tid=501924

Type only who is VIP will be able to use the command and be able to use the objects.
In the command you do:
PHP код:
if(yourvipvariable[playerid] == 0//if the player vip level is 0
{
    return 
SendClientMessage(playerid, -1"You are not VIP");

Reply
#3

Quote:
Originally Posted by ConnorW
Посмотреть сообщение
In the command you do:
PHP код:
if(yourvipvariable[playerid] == 0//if the player vip level is 0
{
    return 
SendClientMessage(playerid, -1"You are not VIP");

No need to waste 3 lines for a simple message...

pawn Код:
if(yourvipvariable[playerid] == 0)  return SendClientMessage(playerid, -1, "You are not VIP");
Or

pawn Код:
if(!yourvipvariable[playerid][Vip]) return SendClientMessage(playerid, -1, "You are not VIP");
Reply
#4

Quote:
Originally Posted by ConnorW
Посмотреть сообщение
In the command you do:
PHP код:
if(yourvipvariable[playerid] == 0//if the player vip level is 0
{
    return 
SendClientMessage(playerid, -1"You are not VIP");

If the variable is a boolean, it will give a tag mismatch so better use:

PHP код:
    if(_:VIP[playerid] == 0)
        return 
SendClientMessage(playerid, -1"You are not VIP"); 
The same thing here

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
No need to waste 3 lines for a simple message...

pawn Код:
if(yourvipvariable[playerid] == 0)  return SendClientMessage(playerid, -1, "You are not VIP");
Reply
#5

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
No need to waste 3 lines for a simple message...

pawn Код:
if(yourvipvariable[playerid] == 0)  return SendClientMessage(playerid, -1, "You are not VIP");
Or

pawn Код:
if(!yourvipvariable[playerid][Vip]) return SendClientMessage(playerid, -1, "You are not VIP");
Really? Lmfao. And why exactly shouldn't he waste more lines to get a clear looking code?
Reply
#6

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
Really? Lmfao. And why exactly shouldn't he waste more lines to get a clear looking code?
Well... An if or else statement can be used without "{ }" if it has just one line, so I believe this form:

PHP код:
if(!IsPlayerAdmin(playerid))
    return 
SendClientMessage(playerid, -1"Insufficient permissions."); 
is neater than this one:

PHP код:
if(!IsPlayerAdmin(playerid))
{
    return 
SendClientMessage(playerid, -1"Insufficient permissions.");

Reply
#7

Quote:
Originally Posted by ConnorW
Посмотреть сообщение
In the command you do:
PHP код:
if(yourvipvariable[playerid] == 0//if the player vip level is 0
{
    return 
SendClientMessage(playerid, -1"You are not VIP");

what is vip variable?
Reply
#8

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
Well... An if or else statement can be used without "{ }" if it has just one line, so I believe this form:

PHP код:
if(!IsPlayerAdmin(playerid))
    return 
SendClientMessage(playerid, -1"Insufficient permissions."); 
is neater than this one:

PHP код:
if(!IsPlayerAdmin(playerid))
{
    return 
SendClientMessage(playerid, -1"Insufficient permissions.");

I really don't care how anyone does it but he made it sound as the second form was somehow wrong, whatever it takes to make a code look more clear is what i'll go for that's why i actually encourage the second form. More lines doesn't mean less processing speed...

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
PHP код:
new bool:VIP[MAX_PLAYERS]; 
And since you've mentioned the usage of the useless bool tag while you're at it might aswell put char arrays in use since it's going to be accepting 1's and 0's (Not that the char array is going to limit it to that) but helps save a bit more.

pawn Код:
new bool:VIP[MAX_PLAYERS char];
And access them using {} instead of [].

pawn Код:
VIP{playerid} = true;
Reply
#9

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
Really? Lmfao. And why exactly shouldn't he waste more lines to get a clear looking code?
A clear looking code, 2 brackets, 1 return, for what? Sending a simple message.

If you think this:

pawn Код:
if (Player[playerid][AccountLevel] < 3) return bla bla;
It's worst than this:

pawn Код:
if (Player[playerid][AccountLevel] < 3)
{
    return bla bla;
}
Are your tastes. However i prefer the first. especially when you have a lot of checks. No need to seriously waste 3 lines....but again, tastes.
Reply
#10

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
No need to waste 3 lines for a simple message...

pawn Код:
if(yourvipvariable[playerid] == 0)  return SendClientMessage(playerid, -1, "You are not VIP");
Or

pawn Код:
if(!yourvipvariable[playerid][Vip]) return SendClientMessage(playerid, -1, "You are not VIP");
There are more ways to do that
pawn Код:
if(yourvipvariable[playerid] > 0)
{
    //continue the code
}
Quote:
Originally Posted by KinderClans
Посмотреть сообщение
A clear looking code, 2 brackets, 1 return, for what? Sending a simple message.
A simple message which will make the player understand why can't he use the command, if you don't do that then the player will get confused and will start asking around. But you're way to lazy to type.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)