OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: RolsRois on 01 Aug 2008, 02:00:49

Title: An easy money problem.. i think :)
Post by: RolsRois on 01 Aug 2008, 02:00:49
ok so i've got the init whice exec in the start:
Cash = 190

really thats it.
now i've made a script of buying a trabant:

_cash = cash
if (_cash <180) then (goto "exit") else goto "ok";

#ok
"Trabant" createvehicle getpos GL1;
cash = _cash - 180
exit


#exit
Dude sidechat "You dont have enough money!"
exit

-------Dude is the player, GL1 is the game logic whice the trabant shows up in------

it just makes the trabant appear, and tells me That i dont have enough money, and the money doesnt go down.
so eventually i get lots of free trabants, whice is good, just not what i want  :P
so, anybody?
Title: Re: An easy money problem.. i think :)
Post by: six6six on 01 Aug 2008, 09:24:47
Code: [Select]
[sub]
_cash = cash
if (_cash <180) then (goto "exit") else goto "ok";

#ok
"Trabant" createvehicle getpos GL1;
_cash = _cash - 180
_cash = cash
exit


#exit
Dude sidechat "You dont have enough money!"
exit[/sub]
I think thats should work.
Title: Re: An easy money problem.. i think :)
Post by: Gcfungus on 01 Aug 2008, 10:13:12
First of all, your first value (Cash) is not the same as (cash), make sure it's the same.
Also, I've edited your script a bit:
Code: [Select]
_cash = cash
?(_cash < 180):goto "cantafford"
"Trabant" createvehicle getpos GL1;
cash = _cash - 180
exit

#cantafford
Dude sidechat "You dont have enough money!"
exit

Have a try with it,
-=GC=-Fungus1999
Title: Re: An easy money problem.. i think :)
Post by: RolsRois on 01 Aug 2008, 19:44:55
Right, i tried GcFungus's solution, and it worked.
tnx for helping guys  :clap:
Title: Re: An easy money problem.. i think :)
Post by: Yasirotta on 04 Aug 2008, 23:59:14
I diddnt want to start new topic, so i put it here.
Has anyone complete money script ? Just scrip for you have money, you can use it and get more. I tried to search old replys but some links has gone old. I believe i can mix up all other things myself, but basic money script is now what i would need.

PS. Why everyone else get "welcome to ofpec" but i diddnt ?  :D
Title: Re: An easy money problem.. i think :)
Post by: Gcfungus on 05 Aug 2008, 10:22:26
I don't think there's such a thing as a simple money script, because every one would be different. If you want help with a script, then you could post what you need and someone could write it for you.
And also :welcome: :welcome:
Title: Re: An easy money problem.. i think :)
Post by: Blacknite on 14 Sep 2009, 04:49:20
Now how do you get this working in multiplayer?  How do you make it apply to one person and not just all?  And vice versa?
Title: Re: An easy money problem.. i think :)
Post by: Rellikki on 14 Sep 2009, 21:53:59
You'd need to change all the variables for every single player. For example, from _cash=x to _cash_player1=x. As I said, it has to be done for every player, so you'd eventually have multiple scripts like that running, with all the players specified in the variables.

I believe there's more practical way for that too, but it does work like that too as I described. Can't really come up with a better way myself.