OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: marcus3 on 14 Mar 2005, 16:59:49
-
ok now i have searched the forum and cant find nothing. no dont blow me up or something. with a money script. can you make it where when trying to buy something you dont have enuff money you dont get it. wood this work
if man1money = 10 and guncost = 20; man you are tyring to buy from sidechat "you dont have enuff money! beat it and dont come back"
or something like that
(came up with all this right off the top of my head)
-
? man1money < guncost : sideChat "blah"
-
dont get it
-
I inferred from your post that the amount of money that man1 has is recorded in the variable man1money. I also inferred from your post that the cost of the gun was held by the variable guncost.
Now, when the two characters meet I presume that a script is called to handle their conversation and the transaction. The line of code I gave goes in the script.
Does that help?
-
me trying right now
-
mmm i am kinda lost do you want the scripts and the mission
i think i will make it cars not guns.
no addons
-
you have the condition however it appears you dont know how conditions work...
example, you put
? jasonmoney < redcarcost
Thats fine but that wont do anything but bring up an error...
I would try this:
?(JasonMoney < 500):titletext ["You bum! you dont have enough money!","Plain Down"];exit
JasonMoney = JasonMoney - 500
hint"You got a car for 500 bucks!"
-
well i hate to say this but.....
i still dont get it do you know where a tut on this is or can you explane it all to me?
-
marcus3, I think the problem is that you do not have sufficient basic scripting knowledge to understand the answers. Before going any further, read
- snYpir's A Friendly Intro to Code Snippets
- Johan Gustafsson's Scripting Tutorial
- Command Reference Scripting Topics Script Syntax (http://www.ofpec.com/editors/comref.php?letter=3#Script%20syntax)
Then look up all of the commands you have used in your script in both the online comref and also the old Unofficial Command reference guide. Then look up all the commands mentioned in this thread.
It sounds like a lot but it isn't really and at the end you'll have a much better understanding of what's going on here. ;)
-
ok......:( i guess i was geting ahead of my self.
-
Hi marcus3
Here's the 20 cent basic tour on what you want to do -
If a variable has a _ in front of it then it only works in that script (eg _target, _JasonMoney). You can't call it or use it anywhere else.
If a variable DOESN'T have a _ in front of it then it stays until the end of the mission or until some script or trigger changes it (eg target, JasonMoney).
You want to use the second type !
If you want to check something in a script then use a question mark or the word "if", your test, a colon (:) or the word "then", and your result (what you want to happen).
So if you made a variable called JasonMoney somehow (maybe by setting it in the player's Init field at start - JasonMoney = 1000), you could then put this in an addaction on an object -
?(JasonMoney < 500):titletext ["You bum! you dont have enough money!","Plain Down"],exit
JasonMoney = JasonMoney - 500
hint"You got a car for 500 bucks!"
The first line says - if JasonMoney is less than 500 then show a message ("You bum . . etc") and exit the script. The rest says "if you didn't exit the script because of that first line then take away 500 of Jason's money and tell him he got the car. I suppose to avoid having the Feds raid this car yard you should also add something that gives Jason his car eg -
"Jeep" camcreate getPos Jason
I hope that this helps. I know that the tutes etc are all very daunting to start off with - when I first saw the comref I thought that I'd never use even a tenth of the commands and now I've used almost every one of them.
Happy scripting !
roni
-
ok thanks man