I need some help with an entrance. - 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: I need some help with an entrance. (
/showthread.php?tid=565152)
I need some help with an entrance. -
zork - 25.02.2015
Hello,
How do I make an entrance to be locked for all the players on the server?
Let's say we've door A which's a faction door. Only the leader can lock the door.
I tried doing:
PHP код:
doorLocked[ MAX_PLAYERS ];
and for example:
PHP код:
CMD:lockdoor( playerid, cmdtext[] ) {
if(IsPlayerConnected(playerid))
{
new string[128]; // the if player is leader etc I know how to do it this is just an example
format(string, sizeof(string), "%s has locked door A", GetOOCName(playerid));
SendMessageToAll(example, red, string);
foreach( new i : Player )
{
doorLocked = 1;
}
return 1;
}
return 0;
}
How do I check if the door's locked & if it is to unlock it, I think I got an idea how to do that but the real question's:
If I do it that way, wouldn't the players that just connect have doorLocked = 0; meaning they can enter the specified door?
To sum it all up, I want someone to show me how to make a door be locked & unlocked for everyone on the server and when it's locked to be locked on those that join too.
Re: I need some help with an entrance. -
ReD_HunTeR - 25.02.2015
pawn Код:
new doorlocked;
public OnGameModeInit()
{
doorlocked = 0;
return 1;
}
public OnGameModeExit()
{
doorlocked = 0;
return 1;
}
CMD:lockdoor(playerid, params[])
{
if(doorlocked == 0)
{
new string[128];
format(string, sizeof(string), "%s has locked door A", GetOOCName(playerid));
SendMessageToAll(example, red, string);
doorlocked = 1;
}
else if(doorlocked == 1)
{
new string[128];
format(string, sizeof(string), "%s has unlocked door A", GetOOCName(playerid));
SendMessageToAll(example, red, string);
doorlocked = 0;
}
return 1;
}
//On Enter Door
if(doorlocked == 0) return SendClientMessage(playerid, 0xFF0000AA, "Door A is locked");
Re: I need some help with an entrance. -
zork - 25.02.2015
Thank you, I'll try it later but as it seems it looks like it'll work. You received +rep.