Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Problem With A Car Script (https://forums.graalonline.com/forums/showthread.php?t=134264383)

Gunderak 08-28-2011 09:44 AM

Problem With A Car Script
 
Basically iv made a car script and it works good but there's one problem.
When accelerating it looks non normal and goes from 0 - top speed instantly.
I am clueless on how i would actually do acceleration.
Ff anyone has any ideas they'd be much appreciated.

Tricxta 08-28-2011 11:50 AM

basically have a counter:

PHP Code:

function onPlayerenters()
{
  
settimer(0.05);
}

function 
onTimeout()
{
  if (
keydown2(keycode("f"),true) && this.speed<this.topspeed)this.speed++;
  else 
this.speed-=0.25;
  
settimer(0.05);


I dont think I've used valid syntax for keydown2 but I can't remember what works and what not o_0, hopefully this will give you an idea on how to do it. But you could always post your script then one of us can examine it and tell you what the problem is lol :), its most likely that you not having the script take a break after the key is pressed. So pop into your script
PHP Code:

sleep (0.05); 

after your speed increment statement

Gunderak 08-28-2011 12:02 PM

ah ok i get the jist of this.
what its doing on a timer its slowly incrementing the speed.
if the keys arent being held down it slowly reduces until its nothing.
also its just using arrow keys btw not f lol.
thanks man.
youv'e given me a new approach on this. :)

Gunderak 08-28-2011 12:09 PM

im not near my pc but i think iv'e found another problem.
how the speed will work is confusing...
i know how to make my self go faster but the on wall check im not so sure about.
maybe somthing like this.
PHP Code:

function onKeydown(code){
if(
code == "37"){ //Left Arrow
if(!onwall(player.1.5player.y){ 

But im not sure if theres an easier way to check if on wall besides manually entering that on each keydown check.

callimuc 08-28-2011 04:29 PM

I would check with keydown from 1-4. Since your car script is kind of it´s own movement, I´d take a look at this one
Dusty´s Bare Bone Movement.
The math might be complicated for the walls check.

Astram 09-01-2011 02:22 AM

you can do a check.
if (keydown(1))

cbk1994 09-01-2011 02:32 AM

Quote:

Originally Posted by callimuc (Post 1665826)
I would check with keydown from 1-4.

Keys 0-3, not 1-4, are for the arrow keys.

callimuc 09-01-2011 02:37 AM

Quote:

Originally Posted by cbk1994 (Post 1666532)
Keys 0-3, not 1-4, are for the arrow keys.

Oh was a quick mistake :blush:

irock1 09-19-2011 02:34 PM

I made a car script but the car pic dosent rotate (car rotates) just the gani dosent help D:

Gunderak 09-21-2011 01:07 AM

Correction: You didnt make it, Astram did.
Dont claim scripts as your own unless you scripted the full script.

irock1 09-30-2011 10:42 AM

just god damn help!

Crow 09-30-2011 11:29 AM

Quote:

Originally Posted by irock1 (Post 1669584)
just god damn help!

Please stop coding.

fowlplay4 09-30-2011 03:28 PM

Quote:

Originally Posted by irock1 (Post 1669584)
just god damn help!

Since you can't get rotation to work, have you tried scripting rotation functionality into your car script?


All times are GMT +2. The time now is 11:12 AM.

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