Quantcast

Jump to content

» «
Photo

[SA] Multiple script but 1 purpose?

63 replies to this topic
Deji
  • Deji

    Coding like a Rockstar!

  • Feroci
  • Joined: 24 Dec 2007
  • None
  • Contribution Award [Mods]

#61

Posted 21 June 2014 - 03:01 PM Edited by Deji, 21 June 2014 - 03:03 PM.

I'm learning fastman92 technique at first post. And I'm still testing. (I'm too slow to learn new things  :bored: )
This time I'm using opcode 0AB3 and 0AB4. Is this script do exactly what I want? I'm sorry to bring this topic back up.

{$CLEO .cs}
:Script1cs
03A4: name_thread "Script1"

:Spawn
wait 0 ms
if
0256:   player $PLAYER_CHAR defined
jf @Spawn
023C: load_special_actor 'TENPEN' as 1 // models 290-299

:Check
wait 0 ms


Noooooo!
 

if
023D:   special_actor 1 loaded
jf @Check
009A: 0@ = create_actor_pedtype 8 model #SPECIAL01 at 213.493 374.339 26.2397  // random coords
0223: set_actor 0@ health_to 2500
0006: 1@ = 0@
0AB3: var 455 = 1@
0A93: end_custom_thread


And I've never seen the help in CLEO vars... they're just as problematic as global vars, perhaps even more so. The more they're used, the more like global vars they will become. And like I said, because your script is in two separate files, other scripts may run in-between them, so that var has a reasonable chance of being totally changed by the next script...
 

{$CLEO .cs}
:Script2cs
03A4: name_thread "Script2"

:Put_Actor
wait 0 ms
0AB4: 1@ = var 455
if
056D:   actor 1@ defined


... in which case, it could crash here, as DOES_CHAR_EXIST is known to do a really unreliable check (one that only works when the handle is already valid).


Think of this like virus protection. If I was a CLEO virus creator (which is a pretty ridiculous concept, I know) I would take advantage of how Windows orders its file searches (CLEO uses the Windows API to load .cs files). Even though your script names, presumably "Script1.cs" and "Script2.cs", will actually load one after another (though not guaranteed to be executed in-order) - it is still possible, easy in fact, for me, a CLEO virus creator, to create a virus which causes 'Script2' to crash...

Compile a script named (no, not with 03A4 - which is pretty useless most of the time, but the file name itself) 'Script1-0.cs' containing the following code:
{$CLEO .cs}
0000:
:viruzzz
wait 0
0@ = -1    // this value will cause a crash when 056D tries to see if the character exists
0AB3: var 455 = 0@    // at the very least (if 056D somehow succeeded or was patched) your script would simply stop working
jump @viruzzz
My virus, which is no more than an ordinary script which could have in fact been a decent mod, will cause your script to crash the game. If my script was installed after yours, the user would come to me and tell me there's a bug in my script. Or, if a user installed my script before yours, they'd be coming to you saying that your script has a bug, and you'll scratch your head for ages wondering why.

Scripts should be made as 'virus'-proof as possible to ensure that no matter what other scripts are running, your script isn't the one to blame for a crashing game. Using two scripts for something that one script should be enough for is a very bad idea.

What exactly is wrong with the method I described?
  • Silent and In45do like this

In45do
  • In45do

    Mack Pimp

  • Members
  • Joined: 15 Jan 2012
  • Indonesia

#62

Posted 22 June 2014 - 04:06 AM

... in which case, it could crash here, as DOES_CHAR_EXIST is known to do a really unreliable check (one that only works when the handle is already valid).



Think of this like virus protection. If I was a CLEO virus creator (which is a pretty ridiculous concept, I know) I would take advantage of how Windows orders its file searches (CLEO uses the Windows API to load .cs files). Even though your script names, presumably "Script1.cs" and "Script2.cs", will actually load one after another (though not guaranteed to be executed in-order) - it is still possible, easy in fact, for me, a CLEO virus creator, to create a virus which causes 'Script2' to crash...

Compile a script named (no, not with 03A4 - which is pretty useless most of the time, but the file name itself) 'Script1-0.cs' containing the following code:
{$CLEO .cs}
0000:
:viruzzz
wait 0
0@ = -1    // this value will cause a crash when 056D tries to see if the character exists
0AB3: var 455 = 0@    // at the very least (if 056D somehow succeeded or was patched) your script would simply stop working
jump @viruzzz
My virus, which is no more than an ordinary script which could have in fact been a decent mod, will cause your script to crash the game. If my script was installed after yours, the user would come to me and tell me there's a bug in my script. Or, if a user installed my script before yours, they'd be coming to you saying that your script has a bug, and you'll scratch your head for ages wondering why.

Scripts should be made as 'virus'-proof as possible to ensure that no matter what other scripts are running, your script isn't the one to blame for a crashing game. Using two scripts for something that one script should be enough for is a very bad idea.

What exactly is wrong with the method I described?

 

I've tested my previous codes and yes, it didn't work. And it's possible that someone will screw the vars if they know which vars I use. But for access checks, the vars is working properly. Thanks for the info. :^:


Deji
  • Deji

    Coding like a Rockstar!

  • Feroci
  • Joined: 24 Dec 2007
  • None
  • Contribution Award [Mods]

#63

Posted 22 June 2014 - 03:55 PM

I've tested my previous codes and yes, it didn't work. And it's possible that someone will screw the vars if they know which vars I use. But for access checks, the vars is working properly. Thanks for the info. :^:


No, what's the problem is: it's possible that someone will screw the vars if they don't know which vars you use.

People aren't trying to write scripts that cause crashes, just as you aren't, but without careful consideration of the worst kind of script which could try to run together with yours, you can prevent a lot of problems.

And still, the method is slower and will be more harder to manage with complex scripts, compared to the method I posted. I can't see why you'd go for something more vulnerable :p
  • In45do likes this

Midnightz
  • Midnightz

    Populus vult decipi.

  • Members
  • Joined: 05 Feb 2007
  • United-States

#64

Posted 27 September 2014 - 08:58 AM

Bumping so I remember to come back around to this when I wish to tear into V's code.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users