03.08.2009, 10:00
Quote:
www.xgweb.co.uk/xgrp FOR DOCUMENTATION READ THIS: http://forum.sa-mp.com/index.php?top...0711#msg710711 |
EDIT: Las Venturas version added! 26/08/09!
See link at very bottom of post.
Tutorial for Red County Version:
At the top, lets forward the custom callbacks we will make later on in the script.
Put this at the top of your script underneath #include's;
pawn Код:
forward BotSwitch(playerid);
forward BotSwitch2(playerid);
forward FinalBotSwitch(playerid);
forward BotEnd(playerid);
Underneath that, lets create a variable to not let the player spam viewing the bots so he gets like 99999 bots at once. (This WILL lag the server like hell, executing loads of timers at once).
Put this under those forwards mentioned earlier;
pawn Код:
new IsOnBots[MAX_PLAYERS]; // this variable is automatically set to 0 (false) when created.
Next we will need to create variables for timers we will have to create later on, so it's easier to kill them when we stop the bots etc;
pawn Код:
new Bot1, Bot2;
Put this under the OnPlayerCommandText callback;
pawn Код:
if(strcmp(cmdtext, "/bots", true) == 0)
{
if(IsOnBots[playerid] == 0)
{
SetPlayerInterior(playerid, 12);
SetPlayerPos(playerid, 1131.6519, -6.1646, 1000.6797);
SetPlayerFacingAngle(playerid, 34.4670);
SetTimerEx("BotSwitch", 1500, false, "i", playerid);
SetTimerEx("FinalBotSwitch", 15000, false, "i", playerid);
IsOnBots[playerid] = 1;
}
else
{
SendClientMessage(playerid, 0xAFAFAFAA, "[ERROR]: You are already viewing bots.");
}
return 1;
}
pawn Код:
public BotSwitch(playerid)
{
SetPlayerInterior(playerid, 0);
TogglePlayerControllable(playerid, false);
Bot1 = SetTimerEx("BotSwitch2", 750, false, "i", playerid);
return 1;
}
Next we will create the code to switch the player's interior back to 12, which is what the "BotSwitch2" timer does mentioned in the code above;
pawn Код:
public BotSwitch2(playerid)
{
SetPlayerInterior(playerid, 12);
TogglePlayerControllable(playerid, true);
Bot2 = SetTimerEx("BotSwitch", 4000, false, "i", playerid);
return 1;
}
The "BotSwitch" timer will execute the callback "BotSwitch(playerid)", so it will create lots of bots in the casino interior and make them fall through the floor, thus making them appear on land, because we don't want the player to see 2 bots walking around, we want 5-10 of them.
Now, on the command code we set this timer;
pawn Код:
SetTimerEx("FinalBotSwitch", 15000, false, "i", playerid);
pawn Код:
public FinalBotSwitch(playerid)
{
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, 1119.9685, 10.6820, 62.1944);
TogglePlayerControllable(playerid, true);
KillTimer(Bot1);
KillTimer(Bot2);
SetTimerEx("BotEnd", 60000, false, "i", playerid);
return 1;
}
Now we will need to create that code;
pawn Код:
public BotEnd(playerid)
{
SpawnPlayer(playerid);
SendClientMessage(playerid, 0xAFAFAFAA, "[INFO]: Bots have been automatically stopped.");
IsOnBots[playerid] = 0;
return 1;
}
Although it all seems fine and dandy, there are a few downsides to this script;
Quote:
If you go out of range the bots disappear. You can't kill them unless you hit them with a spray can (mace). You can only view the bots for 1 minute, but that is easy to change, just change the defination of milliseconds in the "BotEnd" timer mentioned in the "/bots" command. |
A couple of pictures:
Please note: I am not the founder of how to get bots, but I did create this snippet myself so they go on land, but all thanks to http://forum.sa-mp.com/index.php?topic=105658.0
Downloads (Optional):
Red County version (this version is the tutorial):
Click me for download.
Las Venturas version (updated to Las Venturas):
Click me for download.