mattxr 9 Posted October 14, 2007 guy i need this is sqf format can anyone help me. i get a ctd. Quote[/b] ]number = random 60 ?number < 14 : goto "SP1" ?number > 14 AND number < 23 : goto "SP2" ?number > 23 AND number < 30.5 : goto "SP3" ?number > 30.5 AND number < 34 : goto "SP4" ?number > 34 AND number < 41 : goto "SP5" ?number > 41 AND number < 46 : goto "SP6" ?number > 46 AND number < 51 : goto "SP6" ?number > 51 : goto "Exit" ;--------------------------------------------- #SP1 ;Group, Area, ASize, Num Of Enemy [group01,Spa1,400,100] call spawnbuild; exit ;--------------------------------------------- ;--------------------------------------------- #SP2 ;Group, Area, ASize, Num Of Enemy [group01,Spa2,400,100] call spawnbuild; exit ;--------------------------------------------- ;--------------------------------------------- #SP3 ;Group, Area, ASize, Num Of Enemy [group01,Spa3,400,100] call spawnbuild; exit ;--------------------------------------------- ;--------------------------------------------- #SP4 ;Group, Area, ASize, Num Of Enemy [group01,Spa4,200,100] call spawnbuild; exit ;--------------------------------------------- ;--------------------------------------------- #SP5 ;Group, Area, ASize, Num Of Enemy [group01,Spa5,200,100] call spawnbuild; exit ;--------------------------------------------- ;--------------------------------------------- #SP6 ;Group, Area, ASize, Num Of Enemy [group01,Spa6,200,100] call spawnbuild; exit ;--------------------------------------------- ;--------------------------------------------- #SP7 ;Group, Area, ASize, Num Of Enemy [group01,Spa4,200,100] call spawnbuild; [group01,Spa5,200,100] call spawnbuild; [group01,Spa6,200,100] call spawnbuild; exit ;--------------------------------------------- #Exit exit Share this post Link to post Share on other sites
the unknown 0 Posted October 14, 2007 Try useing the switch command Link Share this post Link to post Share on other sites
mattxr 9 Posted October 14, 2007 ? Dont understand, to use the call spawnbuild; i need the script in SQS but to get the random Enemy spawn if any i can only do that in sqs so i need help. Share this post Link to post Share on other sites
vova _fox 0 Posted October 14, 2007 try { number = random 60; if (number < 14) then {throw "SP1"}; if (number > 14 AND number < 23) then {throw "SP2"}; if (number > 23 AND number < 30.5) then {throw "SP3"}; if (number > 30.5 AND number < 34) then {throw "SP4"}; if (number > 34 AND number < 41) then {throw "SP5"}; if (number > 41 AND number < 46) then {throw "SP6"}; if (number > 46 AND number < 51) then {throw "SP6"}; throw "exit"; } catch { switch _exception do { case "SP1" : { //Group, Area, ASize, Num Of Enemy [group01,Spa1,400,100] call spawnbuild; }; case "SP2" : { //Group, Area, ASize, Num Of Enemy [group01,Spa2,400,100] call spawnbuild; }; case "SP3" : { //Group, Area, ASize, Num Of Enemy [group01,Spa3,400,100] call spawnbuild; }; case "SP4 : { //Group, Area, ASize, Num Of Enemy [group01,Spa4,200,100] call spawnbuild; }; case "SP5" : { //Group, Area, ASize, Num Of Enemy [group01,Spa5,200,100] call spawnbuild; }; case "SP6" : { //Group, Area, ASize, Num Of Enemy [group01,Spa6,200,100] call spawnbuild; }; case "SP7" : { //Group, Area, ASize, Num Of Enemy [group01,Spa4,200,100] call spawnbuild; [group01,Spa5,200,100] call spawnbuild; [group01,Spa6,200,100] call spawnbuild; }; case "exit" : {}; }; }; Share this post Link to post Share on other sites
vova _fox 0 Posted October 14, 2007 ? Dont understand, to use the call spawnbuild; i need the script in SQS but to get the random Enemy spawn if any i can only do that in sqs so i need help. you can use command call everywhere Share this post Link to post Share on other sites
mattxr 9 Posted October 14, 2007 ? Dont understand, to use the call spawnbuild; i need the script in SQS but to get the random Enemy spawn if any i can only do that in sqs so i need help.   you can use command call everywhere   it didnt work in the sqs for me. Share this post Link to post Share on other sites
mattxr 9 Posted October 14, 2007 with the one you gave me i get this: Quote[/b] ]Error in expression <n {throw "SP6"}; throw "exit"; } catch { switch _exception do { case "SP1" : { > Error position: < switch _exception do { case "SP1" : { > Error Missing } File C:\Documents and Settings\Matt Rochelle\My Documents\ArmA Other Profiles\-{GOL}-Mattius\mpmissions\(CO20)Driveby.Sakakah\SpawnP.sqf, line 12 Error in expression <n {throw "SP6"}; throw "exit"; } catch { switch _exception do { case "SP1" : { > Error position: < switch _exception do { case "SP1" : { > Error Missing } File C:\Documents and Settings\Matt Rochelle\My Documents\ArmA Other Profiles\-{GOL}-Mattius\mpmissions\(CO20)Driveby.Sakakah\SpawnP.sqf, line 12 Share this post Link to post Share on other sites
vova _fox 0 Posted October 14, 2007 how do you exec this script? if it didn't work in sqs then your function "spawnbuild" write not correctly type you function "spawnbuild" and type how you describe this function Share this post Link to post Share on other sites
mattxr 9 Posted October 14, 2007 in the init.SQF Quote[/b] ]BuildPos=compile preprocessfile "BuildPos.sqf"; SpawnBuild=compile preprocessfile "SpawnBuild.sqf"; [] execvm "SpawnP.sqf"; My version was the same but with a sqs and Quote[/b] ][] exec "SpawnP.sqs"; Share this post Link to post Share on other sites
vova _fox 0 Posted October 14, 2007 in the init.SQFQuote[/b] ]BuildPos=compile preprocessfile "BuildPos.sqf"; SpawnBuild=compile preprocessfile "SpawnBuild.sqf"; [] execvm "SpawnP.sqf"; My version was the same but with a sqs and Quote[/b] ][] exec "SpawnP.sqs"; use this SpawnBuild=compile preprocessfile "SpawnBuild.sqf"; [] exec "SpawnP.sqs"; SpawnP.sqs: number = random 60 ?number < 14 : goto "SP1" ?number > 14 AND number < 23 : goto "SP2" ?number > 23 AND number < 30.5 : goto "SP3" ?number > 30.5 AND number < 34 : goto "SP4" ?number > 34 AND number < 41 : goto "SP5" ?number > 41 AND number < 46 : goto "SP6" ?number > 46 AND number < 51 : goto "SP6" ?number > 51 : goto "Exit" ;--------------------------------------------- #SP1 ;Group, Area, ASize, Num Of Enemy [group01,Spa1,400,100] call spawnbuild; exit ;--------------------------------------------- ;--------------------------------------------- #SP2 ;Group, Area, ASize, Num Of Enemy [group01,Spa2,400,100] call spawnbuild; exit ;--------------------------------------------- ;--------------------------------------------- #SP3 ;Group, Area, ASize, Num Of Enemy [group01,Spa3,400,100] call spawnbuild; exit ;--------------------------------------------- ;--------------------------------------------- #SP4 ;Group, Area, ASize, Num Of Enemy [group01,Spa4,200,100] call spawnbuild; exit ;--------------------------------------------- ;--------------------------------------------- #SP5 ;Group, Area, ASize, Num Of Enemy [group01,Spa5,200,100] call spawnbuild; exit ;--------------------------------------------- ;--------------------------------------------- #SP6 ;Group, Area, ASize, Num Of Enemy [group01,Spa6,200,100] call spawnbuild; exit ;--------------------------------------------- ;--------------------------------------------- #SP7 ;Group, Area, ASize, Num Of Enemy [group01,Spa4,200,100] call spawnbuild; [group01,Spa5,200,100] call spawnbuild; [group01,Spa6,200,100] call spawnbuild; exit ;--------------------------------------------- #Exit exit it must work, or "SpawnBuild.sqf" write not correctly or this BuildPos=compile preprocessfile "BuildPos.sqf"; SpawnBuild=compile preprocessfile "SpawnBuild.sqf"; [] execvm "SpawnP.sqf"; SpawnP.sqf : try { number = random 60; if (number < 14) then {throw "SP1"}; if (number > 14 AND number < 23) then {throw "SP2"}; if (number > 23 AND number < 30.5) then {throw "SP3"}; if (number > 30.5 AND number < 34) then {throw "SP4"}; if (number > 34 AND number < 41) then {throw "SP5"}; if (number > 41 AND number < 46) then {throw "SP6"}; if (number > 46 AND number < 51) then {throw "SP6"}; throw "exit"; } catch { switch _exception do { case "SP1" : { //Group, Area, ASize, Num Of Enemy [group01,Spa1,400,100] call spawnbuild; }; case "SP2" : { //Group, Area, ASize, Num Of Enemy [group01,Spa2,400,100] call spawnbuild; }; case "SP3" : { //Group, Area, ASize, Num Of Enemy [group01,Spa3,400,100] call spawnbuild; }; case "SP4 : { //Group, Area, ASize, Num Of Enemy [group01,Spa4,200,100] call spawnbuild; }; case "SP5" : { //Group, Area, ASize, Num Of Enemy [group01,Spa5,200,100] call spawnbuild; }; case "SP6" : { //Group, Area, ASize, Num Of Enemy [group01,Spa6,200,100] call spawnbuild; }; case "SP7" : { //Group, Area, ASize, Num Of Enemy [group01,Spa4,200,100] call spawnbuild; [group01,Spa5,200,100] call spawnbuild; [group01,Spa6,200,100] call spawnbuild; }; case "exit" : {}; }; }; Share this post Link to post Share on other sites
sickboy 13 Posted October 14, 2007 Nice thing there with the throw and exception switch! Should've payed more attention to what's possible in ArmA Coding it seems as this will give me some nice cleanups in some of my code, thanks ps, you forgot the buildPos=blabla at the first example. Share this post Link to post Share on other sites
sbsmac 0 Posted October 15, 2007 Hmm - exceptions should be for _exceptional_ events! ;-) I'd be more inclined to use a table for this kind of thing. It avoids duplication of code and is more extensible. Code below typed in from memory - I've probably left a few syntax errors in there. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _actions = [ //entries are probability, spawn location, number [14,Spa1,400], [9,Spa2,400], [7.5,Spa3,400], [3.5,Spa4,200], [7,Spa5,200], ... etc ... ]; _total = 0; {_total = _total + _x select 0} foreach _actions; _n = random _total; scopename "out"; { _n = _n - _x select 0; if (_n < 0) then { [group01,_x select 1,_x select 2,100] call spawnbuild; breakTo "out"; }; } foreach _actions; Share this post Link to post Share on other sites
vova _fox 0 Posted October 16, 2007 number = random 60 _conditions= [ {number < 14}, {number > 14 AND number < 23}, {number > 23 AND number < 30.5}, {number > 30.5 AND number < 34}, {number > 34 AND number < 41}, {number > 41 AND number < 46}, {number > 46 AND number < 51} ]; _functions= [ {[group01,Spa1,400,100] call spawnbuild} {[group01,Spa2,400,100] call spawnbuild}, {[group01,Spa3,400,100] call spawnbuild}, {[group01,Spa4,200,100] call spawnbuild}, {[group01,Spa5,200,100] call spawnbuild}, {[group01,Spa6,200,100] call spawnbuild}, { [group01,Spa4,200,100] call spawnbuild; [group01,Spa5,200,100] call spawnbuild; [group01,Spa6,200,100] call spawnbuild; } ]; scopename "find"; _i=0; _f=-1; { if (call _x) then {_f=_i; breakto "find"}; _i=_i+1; } foreach _conditions; if (_f>=0) then {call (_functions select _f)}; Share this post Link to post Share on other sites