26.03.2011, 12:19
(
Last edited by Lewwy; 26/03/2011 at 05:26 PM.
)
Introduction
I'm not really sure if anybody remembers the method in which you could place unsynchronised pedestrians into San Andreas Multiplayer a while back when 0.2.2 was the current build of that time, but the method was never released as far as I know, so I figured a suitable method out and released it. Since then the forum has updated from SMF to vBulletin and I have searched for the topic I created but had no luck, so I'll make another one just in case anybody wants to try this out! (If anybody does find the topic do not worry, more updated the better)
Step 1
First of all we are going to create a new filterscript (SA-MP server directory > pawno > pawno.exe > File > New) in which we will create our script to create the pedestrians.
NOTE: It is recommended that you use a simple gamemode like LVDM for this script, or if you know what you are doing you can implement this into your gamemode instead of running it as a filterscript.
Once the new script has been generated for us, we need to create two timer variables so that when we want to stop the bots, the other functions don't execute straight after it.
Put these at the very top of your script:
Next we need to find the callback that gets called when a player spawns (OnPlayerSpawn(playerid)).
The callback should look like this in the new script:
With this we can start to add the first process of the script which will add the pedestrians.
Simply add this simple code into the callback:
This code will execute when the player spawns, the player will be teleported to a casino which holds the betting pedestrians from single player. Once the player has teleported a timer will start for them which will simply freeze their position and change their interior, but I will explain that part as we move on.
The code should now exactly look like this:
Step 2
The next step to the script is creating the functions that are executed through the timers we created. It is ideal to put these at the bottom of your script:
This code will change the player's interior after 2 and a half seconds of being teleported to the casino. By doing this the betting pedestrians will fall through the casino floor on top of the actual casino building on the outside. Once the bots have fallen the player will get teleported back to the casino and new betting pedestrians will be created automatically, as a result the previous code will re-execute to add more pedestrians on top of the casino outside. (the more the better!)
After some time though, the pedestrians will have to stop being recreated so the player can actually see the bots walking around the streets and interact with them! That is where the "PedStop" timer comes into play.
Below the "PedDrop" function we will have to create the "PedRestart" function that will be executed through a timer:
Instead of copy and pasting the code we placed under the spawn callback earlier, we can simply recall it, and to prevent the "PedStop" timer from being called twice, we have added the "firsttime" player variable to make sure it is only called once. This code will now create more bots and make them fall through the floor until "PedStop" is executed after 20 seconds.
Finally we must add the actual "PedStop" code to our script so that the player can interact with the bots on the streets by aiming their gun and shooting it or whatever. Add this again to the bottom of your script:
First of all you may notice that it asks you to land on the casino floor, this is because when I tested the script and I chose to teleport the player onto the roof when "PedStop" was activated, the pedestrians didn't appear, but they appear if you parachute after them so hey-ho. First of all the "PedDrop" and "PedRestart" timers are being killed just in case they execute after we place the player on the ground (never ending loops are never good!). After that the player is placed on the ground so that interacting with the pedestrians can be enabled as well as recreating the process by respawning, this is achieved by resetting the "firsttime" variable.
Finished!
I know there has been a lot of waffling in this topic due to being in a bit of a rush today. You can see media of the pedestrians walking about below.
Don't forget to press F5 once you are done writing the script!
Please remember that these pedestrians are not synchronised, you cannot go around asking your buddy if he/she can see them, because they won't be able to.
Source:
Pastebin - Will update if neccessary
I'm not really sure if anybody remembers the method in which you could place unsynchronised pedestrians into San Andreas Multiplayer a while back when 0.2.2 was the current build of that time, but the method was never released as far as I know, so I figured a suitable method out and released it. Since then the forum has updated from SMF to vBulletin and I have searched for the topic I created but had no luck, so I'll make another one just in case anybody wants to try this out! (If anybody does find the topic do not worry, more updated the better)
Step 1
First of all we are going to create a new filterscript (SA-MP server directory > pawno > pawno.exe > File > New) in which we will create our script to create the pedestrians.
NOTE: It is recommended that you use a simple gamemode like LVDM for this script, or if you know what you are doing you can implement this into your gamemode instead of running it as a filterscript.
Once the new script has been generated for us, we need to create two timer variables so that when we want to stop the bots, the other functions don't execute straight after it.
Put these at the very top of your script:
pawn Code:
new droptimer[MAX_PLAYERS],
restarttimer[MAX_PLAYERS];
The callback should look like this in the new script:
pawn Code:
public OnPlayerSpawn(playerid)
{
return 1;
}
Simply add this simple code into the callback:
pawn Code:
SetPlayerInterior(playerid, 10);
SetPlayerPos(playerid, 1961.6940, 1007.0735, 992.4688);
TogglePlayerControllable(playerid, 0);
droptimer[playerid] = SetTimerEx("PedDrop", 2500, 0, "i", playerid);
if(GetPVarInt(playerid, "firsttime") == 0)
{
SetPVarInt(playerid, "firsttime", 1);
SetTimerEx("PedStop", 20000, 0, "i", playerid);
}
The code should now exactly look like this:
pawn Code:
public OnPlayerSpawn(playerid)
{
SetPlayerInterior(playerid, 10);
SetPlayerPos(playerid, 1961.6940, 1007.0735, 992.4688);
TogglePlayerControllable(playerid, 0);
droptimer[playerid] = SetTimerEx("PedDrop", 2500, 0, "i", playerid);
if(GetPVarInt(playerid, "firsttime") == 0)
{
SetPVarInt(playerid, "firsttime", 1);
SetTimerEx("PedStop", 20000, 0, "i", playerid);
}
return 1;
}
The next step to the script is creating the functions that are executed through the timers we created. It is ideal to put these at the bottom of your script:
pawn Code:
forward PedDrop(playerid);
public PedDrop(playerid)
{
SetPlayerInterior(playerid, 0);
restarttimer[playerid] = SetTimerEx("PedRestart", 2500, 0, "i", playerid);
return 1;
}
After some time though, the pedestrians will have to stop being recreated so the player can actually see the bots walking around the streets and interact with them! That is where the "PedStop" timer comes into play.
Below the "PedDrop" function we will have to create the "PedRestart" function that will be executed through a timer:
pawn Code:
forward PedRestart(playerid);
public PedRestart(playerid)
{
return OnPlayerSpawn(playerid);
}
Finally we must add the actual "PedStop" code to our script so that the player can interact with the bots on the streets by aiming their gun and shooting it or whatever. Add this again to the bottom of your script:
pawn Code:
forward PedStop(playerid);
public PedStop(playerid)
{
KillTimer(droptimer[playerid]);
KillTimer(restarttimer[playerid]);
SetPlayerInterior(playerid, 0);
GivePlayerWeapon(playerid, 46, 1);
GameTextForPlayer(playerid, "~r~Land on the Four Dragon's Casino Roof!", 2500, 5);
TogglePlayerControllable(playerid, 1);
SetPVarInt(playerid, "firsttime", 0);
return 1;
}
Finished!
I know there has been a lot of waffling in this topic due to being in a bit of a rush today. You can see media of the pedestrians walking about below.
Don't forget to press F5 once you are done writing the script!
Please remember that these pedestrians are not synchronised, you cannot go around asking your buddy if he/she can see them, because they won't be able to.
Source:
Pastebin - Will update if neccessary