Forum Jump :

Author Message

Akasu  



Posts: 15
Rank:


Level: Member

Country: fi
Location: Finland
Occupation:
Age: 20
In-game name:

 
#1 Posted at 2010-05-30 18:27        
     
Hello everybody! I've been making a campaign that includes a mission where you can sell cars for the mafia to get money (to buy weapons) but I can't make a working script for that... I could make many simple scripts for each car but there's like 10 of them so it would be stupid because I know it's possible to do that with only one script.
Here's something I came up with:
;these are the names of the cars.
_vehicles=[civtruck,kar1,ur1,ur2,uaz1,uaz2];
#begin
_x = (_x select _vehicles) //this is the problem. I know that can't be right. I'm totally lost with the 'select' command but I tried experimenting. 
#wait1
?_x distance place < 30: _x addaction ["Sell car","sold.sqs"] ; goto "wait2"
goto "wait1"
#wait2
?sold : goto "dinz" //the "sold.sqs" has a line that makes 'sold' true
?not sold : goto "wait2"
#dinz
_x removeaction 0;
_vehicles=_vehicles - _x; // so the car you sold can't be sold again
_money=_money + 200; // _money is set to 0 in the beginning
sold=false; // reseting the 'sold' 
goto "begin"
So there you have it. After reading the script you might have figured out what I've been trying to do. If not, then basically the '_x' is supposed to be one of the cars you can sell (_vehicles) and when it's near the place (place) where you can sell it, it gets an action "Sell car". Then if you decide to sell it, you get 200 bucks and the script resets.
So if you l33t scripters feel like scripting, could you help me out and make a script like this. Also any help is appreciated. (I need to study that select bad)


Author Message

Dead3yez  

I am evil


Posts: 3115
Rank:


Level: Former Staff

Country: en
Location: North Yorkshire
Occupation: dead3yez
Age: 24
In-game name: dead3yez

 
#2 Posted at 2010-05-31 02:03        
     
http://community.bistudio.com/wiki/select

I'm pretty sure the 'select' command must be used with an index number (0,1,2,3.. etc)


Advertisement


Author Message

Akasu  



Posts: 15
Rank:


Level: Member

Country: fi
Location: Finland
Occupation:
Age: 20
In-game name:

 
#3 Posted at 2010-05-31 13:53        
     
Hmm.. Maybe it goes something like this then:
E: Nope, fail.
_x=0
#start
_vehicles=[civtruck,kar1,ur1,ur2,uaz1,uaz2];
?civtruck distance place < 30 : _x=1; goto "begin"
?_x=0 : goto "start"

#begin
_vehicles select _x addaction ["Sell car","sold.sqs"]
?sold : goto "dinz"
?not sold : goto "begin"

#dinz
_vehicles select _x removeaction 0;
_vehicles=_vehicles - _x;
_money=_money + 200; 
sold=false; 
_x=0;
goto "start"
Have to go try it out.
E:
This one almost worked. The 'car distance place < 30' doesn't work for some reason
_vehicles=[civtruck,kar1,ur1,ur2,uaz1,uaz2];
_x=0;

#start
?civtruck distance place < 30 : _x=1; /everything worked but this. You 
can only sell this car because _x is always 1...
?kar1 distance place < 30 : _x=2;
?_x=1 : goto "begin1";
?_x=2 : goto "begin1";
?_x=0 : goto "start";

#begin1
_vehicles select _x addaction ["Sell car","sold.sqs"];
#begin2
?sold : goto "dinz";
goto "begin2";

#dinz
(_vehicles select _x) removeaction 0;
_vehicles select _x setpos (position awway);
sold=false;
_x=0;
hint "sold";
goto "start";

E2:
_vehicles=[civtruck,kar1,ur1,ur2,uaz1,uaz2];
_x=10; / ? _x=0 I think it selects civtruck anyways. Sneaky.

#start
?civtruck in (list array1) : _x=1; /array1 is the name of a trigger with conditions 'anybody' and 'repeatedly', tested to work with everything else but it won't work here.
?kar1 in (list array1) : _x=2;
?_x=10 : goto "start";
?_x=1 : goto "begin1";
?_x=2 : goto "begin1";

#begin1
_vehicles select _x addaction ["Sell car","sold.sqs"];
#begin2
?sold : goto "dinz";
goto "begin2";

#dinz
(_vehicles select _x) removeaction 0;
_vehicles select _x setpos (position awway);
sold=false;
_x=10;
hint "sold";
goto "start";
Now I'm out of ideas...

This post was edited by Akasu (2010-05-31 18:51, ago)