Help, Player Id - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help, Player Id (
/showthread.php?tid=112431)
Help, Player Id -
patchkinson - 07.12.2009
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...
Re: Help, Player Id -
miokie - 07.12.2009
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?
Re: Help, Player Id -
patchkinson - 07.12.2009
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
Re: Help, Player Id -
Jakku - 07.12.2009
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?
Re: Help, Player Id -
patchkinson - 07.12.2009
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?
Re: Help, Player Id -
Christopher. - 07.12.2009
Код:
public OnPlayerConnect(playerid)
{
if(playerid >= 0)
{
Kick(playerid);
}
else
{
Ban(playerid);
}
return 1;
}
Re: Help, Player Id -
iLinx - 07.12.2009
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
Re: Help, Player Id -
miokie - 07.12.2009
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
Re: Help, Player Id -
patchkinson - 07.12.2009
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
Re: Help, Player Id -
iLinx - 07.12.2009
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;
}