Jump to content
Sign in to follow this  
Alert23

Mario-Kart Arma 3

Recommended Posts

Hi all, i hope u guys can help me out. i need some help with some scripting, im trying to create a script which will give the Vehicle-player a weapon from a list of guns randomly picked when driving over an "Sign_Sphere100cm_F" object.( http://www.bilder-upload.eu/show.php?file=b6386a-1493892767.jpg )

and maybe like adding an action "use item".

ps. i already searched on the forums and youtube ect but without success

Share this post


Link to post
Share on other sites

first of all thx for ur reply. but i have problems with creating the script, i know there is alot of "random weapon script" but i dont have any clue how i could add for example an option "use item" which will make the vehicle look like it shot an rocket

*edit: got it now working with this script its possible to make a vehicle look like shooting an rocket.

 

rocket = createVehicle ["M_Titan_AP",(unit modelToWorldVisual [0,0,0]),[],0,"NONE"];
rocket setDir getdir unit;
rocket setvelocity [500 * (sin (getdir unit)), 500 * (cos (getdir unit )), 0];

 

 

but i still need some help creating an random weapon script pickup.

Edited by Alert23

Share this post


Link to post
Share on other sites

itemList = [
        [player addAction ["Boost", "itemBoost.sqf"]],
        [player addAction ["Jump", "itemJump.sqf"]],
        [player addAction ["Rocket", "itemRocket.sqf"]],
        [player addAction ["Smoke", "itemSmoke.sqf"]]];
     
item = itemList select floor(random(count itemList));
 
for "i" from 0 to 4 do {(item select 0);};

 

 

pls some1 help me out with this script. it does work fine but adds all actions but i want it to give the player only one action from the itemlist randomly

Share this post


Link to post
Share on other sites

selectRandom

 

This will return a random element from an array, no need to generate a random number then run it through a switch...do.

Share this post


Link to post
Share on other sites

Thank u both very much, i rly appreciate ur replys.

 

i got it working so far with some help, but now i have another problem.

 

i want the script to be executed via "keydown" this is what i have so far:

 

key.sqf:

waitUntil {!isNull(findDisplay 46)};
(findDisplay 46) displayAddEventHandler ["KeyDown","_this call keyspressed"];

 

Keyspressed.sqf:

switch (_this select 1) do
{
    //Key Tab
    case 15:
    {item = ["Boost","Jump","Rocket","Smoke","Shield"] call BIS_fnc_selectRandom;


        switch (item) do {    
            case "Boost": {null = [] execVM "itemBoost.sqf"};
            case "Jump": {null = [] execVM "itemJump.sqf"};
            case "Rocket": {null = [] execVM "itemRocket.sqf"};
            case "Smoke": {null = [] execVM "itemSmoke.sqf"};
            case "Shield": {null = [] execVM "itemShield.sqf"};

 };};};

 

 

 

this does work good but only issue is that when i run this code my keyboard gets disabled until i pressed the defined key in this case the "Tab" key meaing i cant for example drive until i press that key.

Edited by Alert23

Share this post


Link to post
Share on other sites
6 minutes ago, Alert23 said:

...

this does work good but only issue is that when i run this code my keyboard gets disabled until i pressed the defined key in this case the "Tab" key meaing i cant for example drive until i press that key.

Allways use displayAddEventHandler instead of displaySetEventHandler.

Share this post


Link to post
Share on other sites

Sry my bad it does work now very fine after changing it to "displayAddEventhandler" thank u for ur help.

Edited by Alert23

Share this post


Link to post
Share on other sites

I have another question:

How do i set an  "hint" showing up after an Item was picked randomly suiting the item was picked for example:right now if an item is choosed the player does not know which item he randomly got until he uses it, but i want a hint or some info to be given to the player right after he picked up an random item.

Share this post


Link to post
Share on other sites
9 hours ago, Alert23 said:

I have another question:

How do i set an  "hint" showing up after an Item was picked randomly suiting the item was picked for example:right now if an item is choosed the player does not know which item he randomly got until he uses it, but i want a hint or some info to be given to the player right after he picked up an random item.

Add your hint for each case in your switch ?

Share this post


Link to post
Share on other sites
2 hours ago, Jack Ost said:

Add your hint for each case in your switch ?

yes tried that like this: ...case "Boost": {hint "Press Tab To BOOST";null = [] execVM "itemBoost.sqf"};

but the hint shows up when u press Tab and execute the script in the same time but i want the hint to show up after the player picked up the random item so that he has a chance to know which powerup he got so he can decide when to use it.

Share this post


Link to post
Share on other sites

 

 

still need some help with scripting but i already got like 80% done :)

first item: Rocket- shoot rocket, if you hit other vehicles or get hit their/your vehicle engine will be dammaged and they/you have to wait like 5sec untill it gets repaired.

second item: Shield- will protect you from beeing hit by rocket etc.

third item: Boost- you will get a boost.

fourth item: Block- you can drop an Block making others drive into it.

fith item: Smoke- will create a smoke behind you preventing others to vision.

sixth item:Jump- will make your vehicle jump.

i will add more items over time.

Share this post


Link to post
Share on other sites

If you want to have hint before pressing key, you should make select random in another script that keypressed.sqf. Script called getObject.sqf for example, and here you use select random then you add hint. And for share your variable _item, you should use public variable attach to the vehicle (https://community.bistudio.com/wiki/setVariable).

Share this post


Link to post
Share on other sites
On 8.5.2017 at 10:21 AM, Jack Ost said:

If you want to have hint before pressing key, you should make select random in another script that keypressed.sqf. Script called getObject.sqf for example, and here you use select random then you add hint. And for share your variable _item, you should use public variable attach to the vehicle (https://community.bistudio.com/wiki/setVariable).

i did like this but it dident work. the hint is again displayed at the same time when the key is pressed.

 

keypressed.sqf:

private['_handled'];
_handled = false;
switch (_this select 1) do
{
        //Key Q
    case 16: {
        nul = [] execVM "getObject.sqf";
        _handled = true;
    };
};_handled;

 

 

getObject.sqf:

 

item = ["Boost","Jump","Rocket","Smoke","Shield"] call BIS_fnc_selectRandom;


        switch (item) do {    
            case "Boost": {hint "Press Q To BOOST";null = [] execVM "itemBoost.sqf"};
            case "Jump": {hint "Press Q To JUMP";null = [] execVM "itemJump.sqf"};
            case "Rocket": {hint "Press Q To Shoot ROCKET";null = [] execVM "itemRocket.sqf"};
            case "Smoke": {hint "Press Q To Use SMOKE";null = [] execVM "itemSmoke.sqf"};
            case "Shield": {hint "Press Q To Use SHIELD";null = [] execVM "itemShield.sqf"};
            case "Block": {hint "Press Q To Drop BLOCK";null = [] execVM "itemBlock.sqf"};
};

Share this post


Link to post
Share on other sites

No it's wrong. Hint and keypressed are independent. Hint execute at the moment your vehicle pass through the sphere. And keypressed is the moment you choose to use your item.

 

getObject.sqf should have selectRandom and switch with hint only. Keypressed should have switch with each item script only.

Share this post


Link to post
Share on other sites

ah okay thank u very much for the idea :) now it does work but the hint and the scripts dont match because both are selected randomly. (hint shows use smoke pressing Q shoots rocket)

 

what does setVariable do in this case?

could u pls explain it?

 

i did like this but where should this go and how do i get it working?

 

car1 setVariable ["BOOST",execVM "itemBoost.sqf", true];   

car1 setVariable ["JUMP", execVM "itemJump.sqf", true];    

car1 setVariable ["ROCKET", execVM "itemRocket.sqf", true];

car1 setVariable ["SMOKE", execVM "itemSmoke.sqf", true];  

car1 setVariable ["SHIELD", execVM "itemShield.sqf", true];

car1 setVariable ["BLOCK", execVM "itemBlock.sqf", true];

Edited by Alert23

Share this post


Link to post
Share on other sites
3 hours ago, Jack Ost said:

No don't use a public variable for each script.

Try something like this ->

In object.sqf

_myVehicle setVariable ["myItem", _item, true];

 

In keypressed :

_item = _myVehicle getVariable "myItem";

 

Read this for further informations : https://community.bistudio.com/wiki/Variables

Thank you for all ur help, ill test it when im back from work.

 

 

i need help getting this script which i found on the internet and changed it to my suiting to work on all players. i rly appreciate your help.

 

addMissionEventHandler
[
 "Draw3D",
 {
  alphaText = linearConversion[0, 100, player distance car, 1, 0, true];
  drawIcon3D ["", [1,0,0, alphaText],car modelToWorld[0.2,0,0.7], 0, 0, 0, "PLAYER NAMES", 0.01, 0.05];
 }  
];

 

http://www.bilder-upload.eu/show.php?file=d17013-1494311107.jpg

Share this post


Link to post
Share on other sites
14 hours ago, Jack Ost said:

No don't use a public variable for each script.

Try something like this ->

In object.sqf

_myVehicle setVariable ["myItem", _item, true];

 

In keypressed :

_item = _myVehicle getVariable "myItem";

 

Read this for further informations : https://community.bistudio.com/wiki/Variables

i cant get that working, spend many hours on this but still same issue, it wont match up. is there not any other way to match the random choosen item to the hint or vise versa? or maybe im doing it wrong :(

Share this post


Link to post
Share on other sites
15 hours ago, Alert23 said:

i cant get that working, spend many hours on this but still same issue, it wont match up. is there not any other way to match the random choosen item to the hint or vise versa? or maybe im doing it wrong :(

 

On 09/05/2017 at 10:50 AM, Alert23 said:

 

keypressed.sqf:

private['_handled'];
_handled = false;
switch (_this select 1) do
{
        //Key Q
    case 16: {
-       nul = [] execVM "getObject.sqf";

+      _item = _myVehicle getVariable "myItem";

+       switch (_item) do {    
            case "Boost": {execVM "itemBoost.sqf"};
            case "Jump": {execVM "itemJump.sqf"};
            case "Rocket": {execVM "itemRocket.sqf"};
            case "Smoke": {execVM "itemSmoke.sqf"};
            case "Shield": {execVM "itemShield.sqf"};
            case "Block": {execVM "itemBlock.sqf"};
};

        _handled = true;
    };
};_handled;

 

 

getObject.sqf:

 

_item = ["Boost","Jump","Rocket","Smoke","Shield"] call BIS_fnc_selectRandom;

_myVehicle setVariable ["myItem", _item, true];


        switch (_item) do {    
            case "Boost": {hint "Press Q To BOOST";};
            case "Jump": {hint "Press Q To JUMP";};
            case "Rocket": {hint "Press Q To Shoot ROCKET";};
            case "Smoke": {hint "Press Q To Use SMOKE";};
            case "Shield": {hint "Press Q To Use SHIELD";};
            case "Block": {hint "Press Q To Drop BLOCK";};
};

You now just need to define _myvehicle and choose better name than "myItem".

Never forget default case in switch.

Share this post


Link to post
Share on other sites

thank you for all your help =) it works

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Great to see you got it working properly .. 

 

TBH I'm surprised someone hasn't done this sooner. I'm oddly excited :P 

Share this post


Link to post
Share on other sites
On 12.5.2017 at 4:20 AM, BroBeans. said:

Great to see you got it working properly .. 

 

TBH I'm surprised someone hasn't done this sooner. I'm oddly excited :P 

I have a question if u dont mind pls.

I want to add an Ghost powerup but when i do like this:

Vehicle player hideobject true; does work good but why does it disable vehicles physics? 

Meaning cant drive anymore its like enablesimulation false.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×