Drake™
Site Member
???
Posts: 175
|
Post by Drake™ on Mar 13, 2016 17:40:05 GMT -6
Two immediate reasons:
1.) In "AssRape();" your randomly selected block of script is redundant. You're setting local variables to get the object IDs of global variables you could just use.
2.) You're getting the object ID of a variable that IS an object ID.
$G1 = getObjectId("MissionGroup\\objamb\\gorg");
That variable will return an object ID. For a clearer view: echo($G1); would return 8428 or something. In AssRape(); you're trying to get the object ID of a non object, but a number. So you'd be better off using this block of code in the random section:
setPosition ( $G1, 2009.98, -4245.48, 284.246); setPosition ( $B1, 2009.98, -4245.48, 284.246); setPosition ( $T1, 2009.98, -4245.48, 284.246); setPosition ( $T2, 2009.98, -4245.48, 284.246);
Although I personally despise using global variables in that manner...that's more than likely your error.
|
|
Drake™
Site Member
???
Posts: 175
|
Post by Drake™ on Mar 14, 2016 21:39:57 GMT -6
This begs a question: Is $AssRape a GROUP of vehicles or ONE vehicle? If the former, then that is your problem.
|
|
Drake™
Site Member
???
Posts: 175
|
Post by Drake™ on Mar 18, 2016 17:23:01 GMT -6
Script Reference: cin_HA.cs
newFormation();
order(); - MakeLeader, Speed, Formation
newFormation(Delta, 0,0,0, 0,-30,0, 0,-60,0 0,-90,0);
order(<insertleadingvehiclevariablehere>, MakeLeader, True); order(<insertleadingvehiclevariablehere>, Speed, High/Low); order(<insertleadingvehiclevariablehere>, Formation, Delta);
The three other vehicles in the same group as the leading vehicle should fall into that formation and follow the leader on the assigned path. So going from that point I would order just the leading vehicle to guard whatever you need guarded...I.E the playerID
|
|
Drake™
Site Member
???
Posts: 175
|
Post by Drake™ on Mar 20, 2016 18:18:41 GMT -6
$assX[1]=2864.65;$assY[1]=-3068.22; $assX[2]=2203.47;$assY[2]=-2050.26; $assX[3]=2009.98;$assY[3]=-4245.48; $assCount=3;
function assRape() { order($AssRape, guard, $playerId); %r=randomInt(1,$assCount);
setPosition($G1, $assX[%r], $assY[%r], getTerrainHeight($assX[%r], $assY[%r])); setPosition($B1, ($assX[%r] + randomInt(-50,50)), ($assY[%r] + randomInt(-50,50)), getTerrainHeight($assX[%r], $assY[%r])); setPosition($T2, ($assX[%r] + randomInt(-50,50)), ($assY[%r] + randomInt(-50,50)), getTerrainHeight($assX[%r], $assY[%r])); setPosition($T1, ($assX[%r] + randomInt(-50,50)), ($assY[%r] + randomInt(-50,50)), getTerrainHeight($assX[%r], $assY[%r])); }
Try that where ever you call the function at. That may work I'm not sure...I can't exactly test it right now.
|
|
Drake™
Site Member
???
Posts: 175
|
Post by Drake™ on Mar 28, 2016 22:41:12 GMT -6
Send me the map, script and everything related to ss.edrake@gmail.com I need to take a look at it...I have a feeling as to what it is, but I can't confirm it without looking at it.
|
|
Drake™
Site Member
???
Posts: 175
|
Post by Drake™ on Mar 29, 2016 20:50:05 GMT -6
Ok...so I found the error. I would like to apologize in advance because this is a common programming error throughout the world. It is known as the PICNIC error. Rather, in this case PICNIP.
Though there is one minor change I have to make due to a -slight- error in my part. I hadn't realized the bumpiness of the terrain so the teleporting script may make the vehicles go under the terrain. To avoid this issue I simply adjusted the terrain height math to account for...hopefully any mishaps.
$assX[1]=2864.65;$assY[1]=-3068.22; $assX[2]=2203.47;$assY[2]=-2050.26; $assX[3]=2009.98;$assY[3]=-4245.48; $assCount=3;
function AssRape() { order($AssRape, guard, $playerId); %r=randomInt(1,$assCount);
setPosition($G1, $assX[%r], $assY[%r], (getTerrainHeight($assX[%r], $assY[%r]) + 20)); setPosition($B1, ($assX[%r] + randomInt(-50,50)), ($assY[%r] + randomInt(-50,50)), (getTerrainHeight($assX[%r], $assY[%r]) + 20)); setPosition($T2, ($assX[%r] + randomInt(-50,50)), ($assY[%r] + randomInt(-50,50)), (getTerrainHeight($assX[%r], $assY[%r]) + 20)); setPosition($T1, ($assX[%r] + randomInt(-50,50)), ($assY[%r] + randomInt(-50,50)), (getTerrainHeight($assX[%r], $assY[%r]) + 20)); }
If not there is a way to make it more accurate, but I simply dislike writing more script than is necessary.
As for the error itself...the reason why your script could not find the vehicles is because I'm assuming you were using the console to test the function. This in mind, the script was being ran client side therefore it could not locate the objects from the server. So, try running the script like so:
focusserver(); AssRape(); focusclient();
That should fix the problem should you test it via console. As for in the script itself that should run just fine. I tested the funciton and the vehicles teleport just fine.
|
|
Drake™
Site Member
???
Posts: 175
|
Post by Drake™ on Mar 31, 2016 17:09:46 GMT -6
It's always something simple, but when you're frustrated just take a step back and relax. A relaxed state of mind sees things a frustrated mind can never see. All else fails, yes ask for help.
Also when scripting, or even writing a complex program, remember this quote:
"Clarity in writing leads to sanity in debugging."
Come up with a set of rules on how you write your scripting. For me, I just tried my best to compile the lines as best as possible and tried to avoid writing too many redundant scripts.
I.E
%rand = randomInt(1,4); if(%rand == 1) { doThisThing(); } else if(%rand == 2) { doThisOtherThing(); } ... etc etc
That can be squished a bit for easier writing and reading:
%r = randomInt(1,4); if(%r == 1) doThisThing(); else if(%r == 2) doThatThing(); else if(%r == 3) doAnoterThingNotThatThing();
... etc etc...
One line if statements don't require brackets. Also, array variables can be your friend with scripting. If you need any help in that department feel free to look at some of my work or just shoot an e-mail. I just happened to view these forums out of curiosity at the right time I guess.
Later.
|
|