Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

I need help regarding the scripting

Here you can find answered ScriptAPI topics.
Forum rules
By using the forum you agree to the following rules.
Post Reply
Marsuplexi
Meatbag
Posts: 2
Joined: Sun Feb 18, 2018 5:10 pm

I need help regarding the scripting

Post by Marsuplexi » Sun Feb 18, 2018 5:52 pm

First of all I'm pretty new to this game and I can't make my own scripts. I don't like asking this but can someone make me a "spawn objects" script that spawns specific objects in a random order? Example: spawn: barrel, box, gun, barrel, monitor, explosive barrel etc. in a random order and in the same place.
0 x

Hoang Marcel
Superfighter
Superfighter
Posts: 62
Joined: Sun Mar 20, 2016 3:40 am
Title: Custom map lover
Started SFD: PreAlpha 1.6.4
Location: Vietnam
Gender:

Post by Hoang Marcel » Mon Feb 19, 2018 2:53 am

List<string> objectlist = new List<string>{"Barrel00","BarrelExplosive","Crate00","WpnKnife","WpnPistol","WpnCarbine"};
Random random = new Random();

public void spawnrandomobject(TriggerArgs arg){
IObject spawnpoint = Game.GetSingleObjectByCustomID("spawnpoint");
int randomnumber = random.Next(5); //Number of objects in the object list
string randomobject = objectlist[randomnumber];
Game.CreateObject(randomobject, spawnpoint.GetWorldPosition());
}

Create a button with script method spawnrandomobject and an invisibleblocknocollision with custom id spawnpoint
Each time you press the button it will spawn a random object at the position of the invisible block
3 x

Marsuplexi
Meatbag
Posts: 2
Joined: Sun Feb 18, 2018 5:10 pm

Post by Marsuplexi » Mon Feb 19, 2018 2:02 pm

Thank you so much! :)
1 x

User avatar
Islem mahmoud
Fighter
Fighter
Posts: 23
Joined: Mon Oct 31, 2016 9:06 am
Title: Producer of [RIOT] clan
SFD Account: El grim
SFD Alias: El grim
Started SFD: March 2012
Location: Algeria
Gender:
Age: 21
Contact:

Post by Islem mahmoud » Mon Mar 05, 2018 11:18 pm

Hoang Marcel wrote:
Mon Feb 19, 2018 2:53 am
List<string> objectlist = new List<string>{"Barrel00","BarrelExplosive","Crate00","WpnKnife","WpnPistol","WpnCarbine"};
Random random = new Random();

public void spawnrandomobject(TriggerArgs arg){
IObject spawnpoint = Game.GetSingleObjectByCustomID("spawnpoint");
int randomnumber = random.Next(5); //Number of objects in the object list
string randomobject = objectlist[randomnumber];
Game.CreateObject(randomobject, spawnpoint.GetWorldPosition());
}

Create a button with script method spawnrandomobject and an invisibleblocknocollision with custom id spawnpoint
Each time you press the button it will spawn a random object at the position of the invisible block
How did u learn this !
0 x
Hell Man »»» El grim

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 375
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 20

Post by JakSparro98 » Wed Mar 07, 2018 2:31 pm

Islem mahmoud wrote:
Mon Mar 05, 2018 11:18 pm
Hoang Marcel wrote:
Mon Feb 19, 2018 2:53 am
List<string> objectlist = new List<string>{"Barrel00","BarrelExplosive","Crate00","WpnKnife","WpnPistol","WpnCarbine"};
Random random = new Random();

public void spawnrandomobject(TriggerArgs arg){
IObject spawnpoint = Game.GetSingleObjectByCustomID("spawnpoint");
int randomnumber = random.Next(5); //Number of objects in the object list
string randomobject = objectlist[randomnumber];
Game.CreateObject(randomobject, spawnpoint.GetWorldPosition());
}

Create a button with script method spawnrandomobject and an invisibleblocknocollision with custom id spawnpoint
Each time you press the button it will spawn a random object at the position of the invisible block
How did u learn this !
Self-study or previous programming skills from his course of study I guess. :)
1 x

User avatar
Islem mahmoud
Fighter
Fighter
Posts: 23
Joined: Mon Oct 31, 2016 9:06 am
Title: Producer of [RIOT] clan
SFD Account: El grim
SFD Alias: El grim
Started SFD: March 2012
Location: Algeria
Gender:
Age: 21
Contact:

Post by Islem mahmoud » Fri Mar 09, 2018 10:27 am

JakSparro98 wrote:
Wed Mar 07, 2018 2:31 pm
Islem mahmoud wrote:
Mon Mar 05, 2018 11:18 pm
Hoang Marcel wrote:
Mon Feb 19, 2018 2:53 am
List<string> objectlist = new List<string>{"Barrel00","BarrelExplosive","Crate00","WpnKnife","WpnPistol","WpnCarbine"};
Random random = new Random();

public void spawnrandomobject(TriggerArgs arg){
IObject spawnpoint = Game.GetSingleObjectByCustomID("spawnpoint");
int randomnumber = random.Next(5); //Number of objects in the object list
string randomobject = objectlist[randomnumber];
Game.CreateObject(randomobject, spawnpoint.GetWorldPosition());
}

Create a button with script method spawnrandomobject and an invisibleblocknocollision with custom id spawnpoint
Each time you press the button it will spawn a random object at the position of the invisible block
How did u learn this !
Self-study or previous programming skills from his course of study I guess. :)
Can you give any book name or channel in youtube that can them help me to learn this shit
& thank you bro
0 x
Hell Man »»» El grim

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 375
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 20

Post by JakSparro98 » Sat Mar 10, 2018 7:12 pm

Islem mahmoud wrote:
Fri Mar 09, 2018 10:27 am
Can you give any book name or channel in youtube that can them help me to learn this shit[..]
Also known as C#. :)
If you google around there are tons of video covering programming languages in general, you can achieve pretty the same level of mine, that I learned programming fundaments at school, but in my opinion I think it's always better to take a complete course (and it results in paying some money for learning) to master programming in the right way, and more importantly, to have constant support of skilled people when problems occurs, and trust me, silly problems will always occur and when you realise what the problem was you will feel like an idiot, personal experience. ;)
1 x

User avatar
Islem mahmoud
Fighter
Fighter
Posts: 23
Joined: Mon Oct 31, 2016 9:06 am
Title: Producer of [RIOT] clan
SFD Account: El grim
SFD Alias: El grim
Started SFD: March 2012
Location: Algeria
Gender:
Age: 21
Contact:

Post by Islem mahmoud » Sun Mar 11, 2018 1:20 pm

:lol: tnx bro ;)
0 x
Hell Man »»» El grim

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest