View Single Post
  #1  
Old 09-14-2002, 11:25 AM
emortylone emortylone is offline
Registered User
Join Date: Apr 2002
Location: Control-NPC
Posts: 834
emortylone is on a distinguished road
New Scripters: Read!

If you're new to scripting, there is one major thing you need to keep in mind. It is better to use variables instead of definitive values. Let me explain:
NPC Code:

if (timeout)
{ if (keydown(0) && strequals(#s(client.string),1))
{ setstring client.string,2;}
if (keydown(0) && strequals(#s(client.string),2))
{ setstring client.string,3;}
if (keydown(0) && strequals(#s(client.string),3))
{ setstring client.string,4;}
if (keydown(0) && strequals(#s(client.string),4))
{ setstring client.string,1;}
timeout=0.1;
}


take THAT where you are setting it to a certain value, which makes editing a SUPER BISH or this:
NPC Code:

if (timeout)
{ if (keydown(0)
{ setstring client.string,#v(#s(client.string)+1);}
if (strtofloat(#s(client.string))=>5)
{ setstring client.string,1;}
timeout=0.1;
}


that makes it so that you have a LOT less coding, and can change things. I put that if the tsring is equal to OR GREAT THAN for a reason. If by some MISHAP or something you end up with 6 or something, then it wouldn't work. I try and build in 'extra protection' so incase something crazy happens and you have a glitch, it still works And when you're doing things, and the same actions will be repeated by more than one event, I find it best to use functions. If you need help with strings and/or this.vars read www.projectshifter.com more coming soon
---Shifter
__________________
Quote:
*Stefan: it seems sometimes they hire newbie scripters everywhere x-x
*Stefan: scripters are sometimes like people that draw paintings
*Stefan: all that counts is that it looks nice
Reply With Quote