09.04.2013, 20:57
(
Последний раз редактировалось Private200; 09.04.2013 в 21:37.
)
Hello fellow Sa;Mp members.
I've seen a lot of members PM-ing me, asking me how to make random timers or things like that. First, before we go on explaining everything required here, just see if you got the requirements below:
This part was showing only 1 function, but, I'm going to show how to use more functions instead.
That's the part of when player spawns, but, it's something random. We can use other things instead of things, as there are houndred and houndred of combinations to use.
Let's see a full part of the code.
I've seen a lot of members PM-ing me, asking me how to make random timers or things like that. First, before we go on explaining everything required here, just see if you got the requirements below:
Skills: 4-5/10 [I ain't good on voting]
Time: 10-20Minutes
Pawno time experience: 1 week - 1 month
Includes number: 1
Includes name: a_samp
So? You got these requirements? If yes, then, let's go!
First, we've got to use news on top of the script so we will be allowed to define what will change. So:
That's it. We just made the first step of the tutorial. Now, we have to use the switch function. Since this tutorial explains it in every case we use it, I'm just going to show part of spawning the player, which can be used for other things except this.Time: 10-20Minutes
Pawno time experience: 1 week - 1 month
Includes number: 1
Includes name: a_samp
So? You got these requirements? If yes, then, let's go!
First, we've got to use news on top of the script so we will be allowed to define what will change. So:
pawn Код:
// This code goes on top of the script, wherever there.
new Randoming;
SWITCH function is being used to switch between the cases we're going to use. Let's see below.
pawn Код:
// This code is going to be under OnPlayerSpawn.
public OnPlayerSpawn(playerid)
{
Randoming = random(2); // ty for reminding O_x
switch(Randoming)
{
case 0: SetPlayerPos(playerid, X, Y, Z); // Instead of this, here, you can use another function or just use more of 1 function. Example will be shown below.
case 1: SetPlayerPos(playerid, X, Y, Z);
}
}
pawn Код:
public OnPlayerSpawn(playerid)
{
Randoming = random(2);
switch(Randoming)
{
case 0:
{
SetPlayerPos(playerid, X, Y, Z); // This will spawn the player and will give him 100 money. You can use more functions here instead of this.
GivePlayerMoney(playerid, 100);
}
case 1:
{
SetPlayerPos(playerid, X, Y, Z);
GivePlayerMoney(playerid, 200);
}
}
}
Let's see a full part of the code.
pawn Код:
// On top of the script
#include <a_samp>
new Randoming;
// Under OnPlayerSpawn or everywhere you want to make random things.
Randoming = random(2);
switch(Randoming)
{
case 0: // Function here
case 1: // Function here
}
That's all guys. You're done. Why not test it? If you're having any problem with it, please leave comment below.