View Single Post
  #2  
Old 09-05-2011, 07:28 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Work on styling and consistency. As a temporary fix you can use this to style your code. For consistency, things like onPlayertouchsme should be onPlayerTouchsMe if you're going to use onActionServerSide.

It also seems like you're using the temp. prefix part of the time and not others. Pick one way and stick with it throughout your script so it's less confusing. As someone who didn't use it except when necessary for years and now does, I'd strongly recommend you use it always.

In your long line of playerdir if-statements, you should be using player.dir, player.x, and player.y. Variables like playerdir and playerx are remnants from GS1 and shouldn't be used in new scripts. You can also probably simplify that entire bit with vecx/vecy.

PHP Code:
function onPlayertouchsme() {
  
addweapon("Personal/kingcj/haticon");
  
clientr.hat_array = {
    
012345
  
};
} else if (
clientr.hat_array = {012345}) { //My goal here was if the player had the weapon it wouldn't reset the hat array... Doesn't work very well. 
  
addweapon("Personal/kingcj/haticon");
}

This doesn't really make sense, it looks like maybe you deleted an if-statement and forgot to delete the else part. Right now that's not even usable code since you've got an extra brace (note the importance of proper indentation in noticing that). Be sure to always use == instead of = for comparison (looks like you are throughout the rest of your script except in that snippet above).

It seems like your script is trying to be part weapon and part NPC. There's no reason to set its image in onCreated since that image is never used. In addition, the onPlayerTouchsMe will never be called in a weapon; that should be moved (along with onCreated) to a level NPC.

Also note that you can't change clientr variables on clientside, so you'll have to trigger serverside to change those.

This is a bit picky, but onCreated should always be at the top of your script (either the very top or right below //#CLIENTSIDE, depending on which side it's run on).
__________________
Reply With Quote