Robbery - 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: Robbery (
/showthread.php?tid=492785)
Robbery -
Crazydriver - 05.02.2014
Hello guys i want to ask that how to make only one player rob the store or big robbery places like bank cause at this moment in my server if a player is robbing other player can also rob at that particular time so please help me?
Re: Robbery -
Mystique - 05.02.2014
Just create a new variable which checks with the server if the bank is being robbed. If someone robs the bank the variable is set to 1 (true) and when the next player comes to rob the bank the script checks if the variable is true or false. If it's true, then just send a message saying that it's being robbed already.
Re: Robbery -
Crazydriver - 05.02.2014
Can you make that for me cause i'm not that good in making variables still a noobish scripter
Re: Robbery -
Beckett - 05.02.2014
As explained above, assign a variable for example
Код:
new Bankrob = 0;
CMD:robbank(playerid,params[]) // or whatever Command Processor are you using.
{
if(Bankrob = 0)
{
// do your code when player can rob bank.
Bankrob = 1; // THIS IS THE MAIN!!!!
} else { SendClientMessage(playerid,-1,"The bank is already being robbed.");
}
That's just an example, sorry for not explaining enough im on my phone.
Re: Robbery -
Mystique - 05.02.2014
Quote:
Originally Posted by DaniceMcHarley
As explained above, assign a variable for example
Код:
new Bankrob = 0;
CMD:robbank(playerid,params[])
{
if(Bankrob = 0)
{
// do your code when player can rob bank.
Bankrob = 1; // THIS IS THE MAIN!!!!
} else { SendClientMessage(playerid,-1,"The bank is already being robbed.");
}
That's just an example, sorry for not explaining enough im on my phone.
|
As explained but you obviously need to create some kind of timer aswell so that when the time finnishes the variable is set to 0.
Re: Robbery -
Beckett - 05.02.2014
Quote:
Originally Posted by Mystique
As explained but you obviously need to create some kind of timer aswell so that when the time finnishes the variable is set to 0.
|
This ^
Re: Robbery -
Crazydriver - 05.02.2014
Yes but i use Mysql DB will this work on there?
Re: Robbery -
Mystique - 05.02.2014
Quote:
Originally Posted by Crazydriver
Yes but i use Mysql DB will this work on there?
|
As long as you don't want the variable to be saved when restarting the server and continue after the restart you won't need mysql. Just use the SetTimer function. Search the forum about how to use it.
Re: Robbery -
davve95 - 05.02.2014
I just lend the topic a bit, I have a similar question..
How to make so you can't rob it again if you already robbed it recently?.
I think it will work with a timer and a variable?
Re: Robbery -
Mystique - 05.02.2014
Quote:
Originally Posted by davve95
I just lend the topic a bit, I have a similar question..
How to make so you can't rob it again if you already robbed it recently?.
I think it will work with a timer and a variable?
|
If you mean that if you rob the bank you can't rob it again for example 1 hour. Yes, then it works with a player variable and a timer.