Occupied Rooms ??? - 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: Occupied Rooms ??? (
/showthread.php?tid=83443)
Occupied Rooms ??? -
Zeromanster - 25.06.2009
Hello,
I wanted to create an interior (in which you go with /enter) but i want the script to check if someone is already inside.
So if someone is inside they would get a message like "Can't go inside right now, it's occupied!" so i started it like this:
On the top of my script i put:
new InRoom[MAX_PLAYERS];
Then i put this in OnPlayerConnect:
InRoom[playerid] = 0;
And then i made my check like this:
pawn Код:
if(InRoom[playerid] == 1)
{
SendClientMessage(playerid, 0xF6345BAA, "Can't go inside sorry ..");
return 1;
}
It worked when i was alone on the server, but will it work for others ?
For instance, if i enter that interior could another player enter aswell ? (with my code)
Please tell my if this code is ok, or if it's not please tell me how to fix it. THANKS
Re: Occupied Rooms ??? -
bigcomfycouch - 25.06.2009
I'm no expert coder, but I'm guessing this might work
Код:
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(InRoom[i] == 1)
{
SendClientMessage(playerid, 0xF6345BAA, "This room is already occupied. Try again later.");
return 1;
}
}
}
Re: Occupied Rooms ??? -
Zeromanster - 25.06.2009
I think this would work, but as i don't have the oportunity to test this, with 2 or more players right now, could someone confirme this ? thanks
Re: Occupied Rooms ??? -
dice7 - 25.06.2009
None of those will work, since you use InRoom is an array for playerids. And because two players can't have the same id, the room will be open for everyone
Re: Occupied Rooms ??? -
Joe Staff - 25.06.2009
You have to do a check if anyone else is in the room
pawn Код:
for(new i; i<MAX_PLAYERS; i++)if(InRoom[i])return SendClientMessage(playerid,0xFF0000FF,"OCCUPADO!");