Jump to content
Sign in to follow this  
Somerville

Earnings script

Recommended Posts

Hi folks,

I've started rewriting the Sahraniville mission, because the old scripts were a tad buggy (Seeing as it was more or less a port of CrimeCity OFP scripts to ArmA). Anyway, I've hit a snag. I'm using SPON Core & Money, and that's great. I did have the earnings script working, but now it doesn't want to behave. My aim is to have an RPG map without constraints on player numbers. So far, I've got this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = _this select 0

?!(player == _unit): exit

_factorypay = 100;

_fishpay = 450;

_coppay = 650;

#begin

~60

hint format ["You will be paid in 2 minutes"]

~60

hint format ["You will be paid in 1 minute"]

~60

hint format ["You will be paid in 30 seconds"]

~15

hint format ["You will be paid in 15 seconds"]

?(_unit == Player) AND (_unit distance factory < 47) : goto "factory"

?(_unit == Player) AND (_unit distance fish < 100) : goto "fish"

?(side Player == WEST) : goto "cops"

hint format ["You're not near enough a place of work"]

goto "begin"

#factory

SPON_playerCashBalance = SPON_playerCashBalance + _factorypay

hint format ["%1, you have been paid $%2. You now have $%3", name player, _factorypay, SPON_playerCashBalance]

~5

goto "begin"

#fish

SPON_playerCashBalance = SPON_playerCashBalance + _fish

hint format ["%1, you have been paid $%2. You now have $%3", name player, _fishpay, SPON_playerCashBalance]

~5

goto "begin"

#cops

SPON_playerCashBalance = SPON_playerCashBalance + _coppay

hint format ["Officer %1. The state has paid you $%2. You currently have $%3 Cash.", name player, _coppay, SPON_playerCashBalance]

~5

goto "begin"

exit

But it seems to say that you're never near a place of work. A fellow mission maker and I put this down to the fact that some players weren't near a place of work, so everyone gets the hint for each player, but should still get the money. But nobody gets any money, even if they are at the place of work. I believe this is because ArmA's 'jumping' to the hint about not being close enough, because somebody isn't.

I tried using the CrimeCity format of having different messages, and using groupChat to show these, but this doesn't work at all - nothing displays.

Just wondering if anyone has any tips for rectifying this issue, or even if anyone's got any suggestions - I'm just looking for some help smile_o.gif Credit will be given in ze readme!

Share this post


Link to post
Share on other sites

hmmm... I'm not quite sure. I'm very very shortly familiarized with scripting but today I put a script in a mission I am making with groupchat, I know you have probably done this, because Sahraniville has many many scripts and you know tons and tons more than I will ever. BUT did you try putting player groupchat instead of _player groupchat?

this maybe way off and sorry if it doesn't help what so ever sad_o.gif , but hell I tried wink_o.gif In fact just stop here. SCROLL down to Spooner he truly knows what he is talking about.

maybe this

Quote[/b] ]#begin

~60

player groupchat ["You will be paid in 2 minutes"]

~60

player groupchat ["You will be paid in 1 minute"]

~60

player groupchat ["You will be paid in 30 seconds"]

~15

player groupchat ["You will be paid in 15 seconds"]

?(_unit == Player) AND (_unit distance factory < 47) : goto "factory"

?(_unit == Player) AND (_unit distance fish < 100) : goto "fish"

?(side Player == WEST) : goto "cops"

player groupchat ["You're not near enough a place of work"]

goto "begin"

#factory

SPON_playerCashBalance = SPON_playerCashBalance + _factorypay

player groupchat ["%1, you have been paid $%2. You now have $%3", name player, _factorypay, SPON_playerCashBalance]

~5

goto "begin"

--------------------------------

and add if you don't already- a marker named fish, factory or whatever then add this in a script or something

Quote[/b] ]if ((unit getpos [(getMarkerPos "markername") select 0, (getMarkerPos "markername") select 1, 0] then : goto "fish" or whichever

Not sure if this works or helps but hopefully it does smile_o.gif

-----------------------------------

Again I'm truly sorry if this was a waste of time reading confused_o.gif

Looking forward to the new release. PS: SPON_money is awesome but confused the hell out of me, have you guys tried the Roleplay Objects, I'm assuming you have cuz the Sahraniville team was mentioned in the ReadMe for testing.

Share this post


Link to post
Share on other sites

Your waiting scheme is incorrect and should be:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#begin

hint format ["You will be paid in 2 minutes"]

~60

hint format ["You will be paid in 1 minute"]

~60

hint format ["You will be paid in 30 seconds"]

~30

hint format ["You will be paid in 15 seconds"]

~15

You don't want to check (_unit == player) each time the script runs around, otherwise when you respawn, the value of player will change relative to _unit and the script will stop working. In fact, you should never use _unit at all or even pass it to the file, since it is unnecessary. Instead, run the script from init.sqs rather than from every player init field and have, at the top of the script:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? isServer and (isNull player) : exit

Which will only run the script once on each client without the faff (that is, don't run it on the dedicated server, but do run on dedicated client, hosted MP server/client or in SP).

To check the distances, just:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? (player distance factory) < 47 : goto "factory"

? (player distance fish) < 100 : goto "fish"

Not sure if that fixes all your problems, but should move you on. I think the question you are asking is probably associated with fish and factory being markers rather than objects. In this case, you need to do:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? (player distance (getMarkerPos "factory")) < 47 : goto "factory"

? (player distance (getMarkerPos "fish")) < 100 : goto "fish"

I think you also want to add the money to SPON_playerBankBalance, which is a global variable, since SPON_playerCashBalance isn't actually a global and isn't used by SPON Money any more (I moved it to being an object variable on the current player object, which made it teamswitch-compatible). Pay usually goes into the bank in such situations anyway, rather than directly into your pockets.

@DaChevs: Sorry you found SPON Money confusing! The problem with making something that is very generic is that it can be difficult to configure to your liking and I'm also fully aware that the documentation I provided was very poor. If you have any problems installing it, don't hesitate to ask in the OFPEC release thread or directly to me (my email is in every one of my released files).

Share this post


Link to post
Share on other sites

What Spooner said smile_o.gif

@Spooner--No Problem--I got it all set up and everything just I couldn't get paychecks to work---but hey---here it is lol. Plus when I first used it I was a n00b at scripting. Now I have much broader (if thats how u spell it) knowledge of scripting and might give it another go. wink_o.gif Your script is awesome either way Spooner, I'm just a n00b thumbs-up.gif

Share this post


Link to post
Share on other sites

no huh.gif Do you need to have goto commands in sqs only?

what happens for me say I have this

?(Side == Civilian) goto "Side1" in an sqf, when I preview the mission my game crashes and I get an error message like somethin something error number 7.

Share this post


Link to post
Share on other sites

"goto" only works for sqs.

and also. sqs scripts are called with exec while sqf with execvm

Share this post


Link to post
Share on other sites

Spooner,

I love you. You fixed it. Now you can earn money - yay! The only thing that doesn't work now is hinting if you're not close enough, but I'm working on that smile_o.gif

Thanks,

Share this post


Link to post
Share on other sites

ETA on the new version Somerville? huh.gif

@nuxil ah ok no wonder I always crashed wink_o.gif Thanks.

Share this post


Link to post
Share on other sites

Well, the new version's progressing well now. Each major city has a bank thanks to the versatility of SPON money, and there's also plenty of shops. The things I need to get done are:

<ul>

[*]Arrest script

[*]Breifing/Documentation [This will have rules/laws/guidelines, like "Drive on the left" or whatever]

And some other stuff. I guess I'd also like to be able to implement the Licence aspect of it in with SPON Money, so you have to have a gun licence for example. But I'm looking into this. A very early Alpha version of the mission is something I'll be looking to test next week, possibly Wednesday evening, mainly to test the features and make sure they're working.

Share this post


Link to post
Share on other sites

Maybe with the licensing you could use Roleplay OBjects, I was gonna go this for my mod The City Life, but I'm not sure if I am going to make it because I'm not very good, and Sahraniville will kicks it's a$$.

But with the Roleplay Objects--there are actual passports, so you could put them in the shop, and use this--

checklicense.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (("" in weapons player) || ("RPO_obj12" in magazines player)) then

{

player groupchat "I can buy a gun now."; GunLicenseBuilding addaction ["Buy Firearm", "Whatever.sqs'];

}else{

player groupchat "I don't have a Firearm License.";

};

Then a trigger around the Shop--Init-"name" exec "checklicense.sqs"'

This will check if the player has the passport, and if the player does then the action to buy a gun will be added to the building or whatever.

Hopefully this helps, it should work.

Also might I suggest for some flavor in the new version--

Car1

Car2

Car3

Car4

-----------------------------------------

The Class names for the DodgeViper:

Viper or Viper 1 = Red

viper2 = black

Cobra Shelby Classname = Cobra

Skoda felicia classname = ffs_felicia

or ffs_felicia_tun for the tuned one

Share this post


Link to post
Share on other sites

Hey DaChev,

Thanks for the check licence thing. That'd be great if we could use those objects smile_o.gif We're also looking for drug objects (Models for Cocaine, Heroin, Weed that sort of stuff). I think we saw some before, but we can't remember where. The idea with this approach to drugs is that they're not imaginary as per CrimeCity - they're tangible, real things, that if you get shot you can get robbed of.

Regarding the licences - would it be possible for us to use them? The only licences I think needed would be Gun, Air and maybe car. The other thing is, I'm looking to have it so that the police may check if a unit has a given license. Jason, a member of the team, reckons using arrays could help this - do you think this would be the case?

Share this post


Link to post
Share on other sites

No Problem. here is a link to the roleplay objects with probably everything you are looking for. it has passports, watches, cellphones, cocaine, dope and even alchohol objects, plus tons more!

Roleplay Objects

As for the police checking the license how bout having the action on the civs for check license. Then use that same code but switch it to whatever object you want, that way it will check if the civ has the object in his inventory and if the civ doesn't then it says this civ has no license!

so like--

in the init field of the civ something like

"cops" addaction ["Check License", "CLicense.sqs"]

CLicense.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (("something" in weapons player) || ("something" in magazines player)) then

{

player groupchat "This civ is licensed to handle a firearm.";

}else{

player groupchat "This civ has no licenses.";

};

Hope this helps more wink_o.gif

Share this post


Link to post
Share on other sites

Ok this is a big question Somerville and I understand if you don't want me to.

Would you mind if I used the old Sahraniville for a mod, and sort of edit it in with a new money system and things, if I have GOL and you mentioned for the complete template? huh.gif

sort of as a base.

Again--please tell me no if you wish for me not to. thumbs-up.gif

Share this post


Link to post
Share on other sites

As long as GOL/Sahraniville are credited, then sure go for it smile_o.gif

Edit I've just tried incorporating the RolePlay Objects, but no joy. SPON Money doesn't seem to like it for some reason. For example, I put RPO_Obj19 (UK Passport) as a magazine available for sale, but SPON said "Non!". Then I tried it as a weapon, a vehicle, a hand grenade, optics... no joy! So I'm not sure if it'll be able to get into Sahraniville sad_o.gif

I'll email Spooner, see if he knows how to get around it.

Share this post


Link to post
Share on other sites

Ok thanks. I don't need much but your scripts are awesome and it would help alot. smile_o.gif

As for the Roleplay Objects, if your not able to put them in an actual shop, you could always create a custom shop, and just have the objects you want and remove the money like in the paychecks where you just use the variable. confused_o.gif

Share this post


Link to post
Share on other sites

Ah it's okay now fella, it's working. I'm hoping I'll be able to convert one of the Passports to a driver's liscence, and another one to a gun licence.

Share this post


Link to post
Share on other sites

Ok good. I'm going to try and create a few objects. I'll try and make a license or two. Also gonna work on a police car.

*EDIT* not done yet...

license.jpg

Share this post


Link to post
Share on other sites

Ah, I'm also working on one - it's based on my UK License for driving smile_o.gif Good work DaChevs, keep it up!

Also, I'm working with that script you posted before to check licenses. So far, I've got this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; ****************************************************************

; Script file for Armed Assault

; Created by: TODO

; License checking facility for Sahrani PD

; ****************************************************************

_civ = _this select 0

_cop = _this select 1

if ("RPO_Obj18" in weapons _civ) then

{

hint Format ["%1 holds a full Sahrani License", name _civ]

}else{

hint Format ["%1 does not hold a Sahrani License", name _civ]

};

But that throws back an error.. something about not liking "{" or something. Any ideas why? 0.o

Share this post


Link to post
Share on other sites

hmmm..not quite sure, I got that error two when I tried adding things into the script.

Try making it--

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_player= _this select 0;

_cop = _this select 1;

if (("RPO_Obj18" in magazines player)) then

{

hint Format ["%1 holds a full Sahrani License", name player];

}else{

hint Format ["%1 does not hold a Sahrani License", name player];

};

That might show the player on everyone's screen not, like if I was in game and someone checked me, on my screen it would say "DaChevs has no license", on yours it would say "Somerville has no license"-- I'm not quite sure. I don't think it will though.

checked this in game. It shows the hint, but still says error mission "{" and "};"

I can't get it to work no matter what.

Share this post


Link to post
Share on other sites
The Class names for the DodgeViper:

Viper or Viper 1 = Red

viper2 = black

Cobra Shelby Classname = Cobra

Skoda felicia classname = ffs_felicia

or ffs_felicia_tun for the tuned one

Please tell me your not going to use the DodgeViper and Shelby in an RPG mission.

Please test them, you cant shoot throught the windows, you cant shoot out the tyres and they will take alot of ammo until they explode. They also get stuck on bridges (Like sink in and can't move)

I know, I put them into sarhani life and after a couple of days people were complaining that the cars were invincible.

Nice to look at and drive, no good for pvsp. Just give them a T72 with no ammo would be just the same.

I dare you to just test the 911 Police car, lol that thing can take 2 AT rounds, and when it explodes it go's off like a GBU, hahahaha

Share this post


Link to post
Share on other sites

wow, guess I won't include them... confused_o.gif The Felicia works well as far as I know though.

Share this post


Link to post
Share on other sites

I'm not saying don't add them, maybe make them more expensive. They do explode but seems hard compaired to others to do so.

The bridge problem it common with addon cars i see looking at thit topic

http://www.flashpoint1985.com/cgi-bin....t=72694

There are lots of other vehicles which are really good though, i will keep them in your other topic.

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  

×