Help, Player Id
#1

How do i make that if OnPlayerConnect if player Id is 0 or 2 or 3 or 4 or 5 or 7 or 8 kick
else ban
i just need to know that with player id's, like make if player id is 0 2 4 5 6 7 8 do this: else...
Reply
#2

pawn Код:
public OnPlayerConnect(playerid)
{
  if(playerid == 0 || playerid == 2 || playerid == 3 || playerid == 4 || playerid == 5 || playerid == 7 || playerid == 8)
  {
    Kick(playerid);
  }
  else
  {
    Ban(playerid);
  }
  return 1;
}
Like That?
Reply
#3

Quote:
Originally Posted by Miokie*
pawn Код:
public OnPlayerConnect(playerid)
{
  if(playerid == 0 || playerid == 2 || playerid == 3 || playerid == 4 || playerid == 5 || playerid == 7 || playerid == 8)
  {
    Kick(playerid);
  }
  else
  {
    Ban(playerid);
  }
  return 1;
}
Like That?
exactly thanks
Reply
#4

Quote:
Originally Posted by patchkinson
How do i make that if OnPlayerConnect if player Id is 0 or 2 or 3 or 4 or 5 or 7 or 8 kick
else ban
i just need to know that with player id's, like make if player id is 0 2 4 5 6 7 8 do this: else...
Sorry I ask, but where in hell do you need this?
Reply
#5

Quote:
Originally Posted by Jakku
Quote:
Originally Posted by patchkinson
How do i make that if OnPlayerConnect if player Id is 0 or 2 or 3 or 4 or 5 or 7 or 8 kick
else ban
i just need to know that with player id's, like make if player id is 0 2 4 5 6 7 8 do this: else...
Sorry I ask, but where in hell do you need this?
surprise, the effect is not actually kick or ban, its other thing, but when i put all pair ID's till 500 it says its too long, how can i do?
Reply
#6

Код:
public OnPlayerConnect(playerid)
{
  if(playerid >= 0)
  {
    Kick(playerid);
  }
  else
  {
    Ban(playerid);
  }
  return 1;
}
Reply
#7

Quote:
Originally Posted by Miokie*
pawn Код:
public OnPlayerConnect(playerid)
{
  if(playerid == 0 || playerid == 2 || playerid == 3 || playerid == 4 || playerid == 5 || playerid == 7 || playerid == 8)
  {
    Kick(playerid);
  }
  else
  {
    Ban(playerid);
  }
  return 1;
}
Like That?
pawn Код:
public OnPlayerConnect(playerid)
{
  if(playerid >= 0 && playerid <= 8)
  {
    Kick(playerid);
  }
  else
  {
    Ban(playerid);
  }
  return 1;
}
better imo, cleaner code
Reply
#8

Quote:
Originally Posted by iLinx
Quote:
Originally Posted by Miokie*
pawn Код:
public OnPlayerConnect(playerid)
{
  if(playerid == 0 || playerid == 2 || playerid == 3 || playerid == 4 || playerid == 5 || playerid == 7 || playerid == 8)
  {
    Kick(playerid);
  }
  else
  {
    Ban(playerid);
  }
  return 1;
}
Like That?
pawn Код:
public OnPlayerConnect(playerid)
{
  if(playerid >= 0 && playerid <= 8)
  {
    Kick(playerid);
  }
  else
  {
    Ban(playerid);
  }
  return 1;
}
better imo, cleaner code
He wants to Miss out ID: 1.

So It would be:

pawn Код:
public OnPlayerConnect(playerid)
{
  if(playerid == 0 || playerid => 2 && playerid <= 8)
  {
    Kick(playerid);
  }
  else
  {
    Ban(playerid);
  }
  return 1;
}
I was in a rush when I gave him that answer and completly forgot about >'s and <'s
Reply
#9

thanks
so if i put
pawn Код:
public OnPlayerConnect(playerid)
{
  if(playerid >= 0 && playerid <= 500)
  {
    Kick(playerid);
  }
  else
  {
    Ban(playerid);
  }
  return 1;
}
its only for even numbers?? cose i need only for even
Reply
#10

to get even numbers you need to use a operator called modulus (%) what mod does is get the remainder of a divison operation.
for example 5/2 will return 1, becuase 5 divided by 2 has a remainder of 1. but 4/4 has a remainder of 0 (this is how you check for even or odd)

pawn Код:
public OnPlayerConnect(playerid)
{
  if(playerid%2 == 0) {
  //execute whatever you want to do if the playerid is even
  }
  else {
  //execute whatever you want to do if the playerid is odd
  }
  return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)