Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-21-2009, 11:53 PM
GULTHEX GULTHEX is offline
Registered User
Join Date: Jul 2008
Posts: 148
GULTHEX can only hope to improve
please help me with this gun script

PHP Code:
//#CLIENTSIDE
//up
if (playerdir=0){
  
this.x=playerx-1;
  
this.y=playery-2;
}
//left
if (playerdir=1){
  
this.x=playerx-2;
  
this.y=playery;
}
//down
if (playerdir=2){
  
this.x=playerx+1;
  
this.y=playery+2;
}
//right
if (playerdir=3){
  
this.x=playerx+2;
  
this.y=playery;
}
if (
playerenters) {
  
toweapons Test;
}
if (
weaponfired){
  
setshootparams PARAMEQUALS;
  
//shoot x,y,z,angle,zangle,power,gani,ganiparams;
  
shoot this.x,this.y,playerz,(playerdir 1) * pi 2,,,dg_bullet,;
  
setani dg_m16-fire,;
  
replaceani idle,dg_m16-idle;
  
replaceani walk,walk;
  
freezeplayer 0.0383;
  
sleep 0.1;
}

if (
actionprojectile) {
  if(
strequals(#p(index),PARAMEQUALS)) {
    
setani hurt,;
    
clientr.hp -= 20;   
  }
  } 
kk the prob is that when the bullet hits people it does damage with hearts it dont minus the hp idk what the prob is it dont even say hearts in the script lol



so whats the prob

and dont nag me about the paremequals it still works
Reply With Quote
  #2  
Old 02-22-2009, 04:51 PM
RozenMaiden RozenMaiden is offline
Registered User
Join Date: Dec 2008
Posts: 27
RozenMaiden is on a distinguished road
So thats essentially the same thread as before just with "dont nag me about paramequals" added? o.ô
Reply With Quote
  #3  
Old 02-22-2009, 05:03 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
clientr.hp must be decreased serverside.
__________________
Reply With Quote
  #4  
Old 02-22-2009, 08:27 PM
GULTHEX GULTHEX is offline
Registered User
Join Date: Jul 2008
Posts: 148
GULTHEX can only hope to improve
so how would i do that


would i do that with a class???
Reply With Quote
  #5  
Old 07-31-2009, 01:31 PM
[email protected] jamerson61894@yahoo.com is offline
Banned
Join Date: Jul 2008
Posts: 83
jamerson61894@yahoo.com is an unknown quantity at this point
This kid asked for help on a script, not how he would get some help. sheesh

Gulthex since this is my gun script, I am quite pissed, however I will show you a simple way of making it serversided.

put this at the top of the script!
PHP Code:
function onActionServerSidecmd )
{
  switch( 
cmd )
  {
    case 
"hp":
    {
clientr.hp -= 10;    //PUT WATEVER YOU WANT IT TO -
  
}
 }

Then put this at the bottom where you currently have the actionprojectile:
PHP Code:
if (actionprojectile
{
  if(
strequals(#p(index),PARAMEQUALS)) 

triggerserver("weapon"this.name"hp");   //TRIGGERS SCRIPT AT TOP
 
}

Also heres a little tip for you. after you script a script, go to rc and type :

If it's a weapon script:
PHP Code:
/style weapon WEAPON NAME 
if it's a NPC script:
PHP Code:
/style npc NPCNAME 
if it's a class:
PHP Code:
/style class CLASSNAME 
I hope this helped ;D
Reply With Quote
  #6  
Old 07-31-2009, 01:48 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
Quote:
Originally Posted by [email protected] View Post
Then put this at the bottom where you currently have the actionprojectile:
PHP Code:
if (actionprojectile
{
  if(
strequals(#p(index),PARAMEQUALS)) 

triggerserver("weapon"this.name"hp");   //TRIGGERS SCRIPT AT TOP
 
}

You shouldn't be mixing GS1 and GS2 like that.

PHP Code:
function onActionProjectile(param) {
  if (
param == "gun") { // or "PARAMEQUALS", lol...
    
triggerserver("gui"name"hp");
  }

Quote:
Originally Posted by [email protected] View Post
Also heres a little tip for you. after you script a script, go to rc and type :
[...]
You really should get into the habit of just pressing tab as you script. RC keeps your indentation for a reason. You'll find it's well worth it once you're used to scripting properly.
__________________
Reply With Quote
  #7  
Old 07-31-2009, 01:59 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Shouldn't it be params[0]?
Reply With Quote
  #8  
Old 07-31-2009, 02:00 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
Quote:
Originally Posted by DustyPorViva View Post
Shouldn't it be params[0]?
Normally, but I did this:

Quote:
Originally Posted by cbk1994 View Post
PHP Code:
function onActionProjectile(param) { 
declaring the first parameter to be placed in the variable 'temp.param'.
__________________
Reply With Quote
  #9  
Old 07-31-2009, 02:03 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Oh, hadn't noticed that :P ... that's very misleading though, and not something I'd suggest for readability and all.
Reply With Quote
  #10  
Old 07-31-2009, 02:09 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
Quote:
Originally Posted by DustyPorViva View Post
Oh, hadn't noticed that :P ... that's very misleading though, and not something I'd suggest for readability and all.
As a general rule, the first projectile param should be the type of projectile. It'd probably be better to use something like projType (which would be, for example, gun, grenade, etc).
__________________
Reply With Quote
  #11  
Old 07-31-2009, 03:36 PM
[email protected] jamerson61894@yahoo.com is offline
Banned
Join Date: Jul 2008
Posts: 83
jamerson61894@yahoo.com is an unknown quantity at this point
Well mine would work so....
Reply With Quote
  #12  
Old 07-31-2009, 03:42 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by [email protected] View Post
Well mine would work so....
Just because it works doesn't mean it's the best way. As a scripter you need to always look for better alternatives and to be more efficient. There are tons of ways to achieve a desired outcome with scripts, and just because they can all achieve what you want doesn't mean it's the right way to go about it. Mixing GS1 and GS2 is not only a bad exercise for the scripter, it's also bad for those reading and trying to learn from the script.

This is no cut on you or anything, but more like advice.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 03:34 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.