SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 18/04/2009, 05:12 PM   #1
Tannz0rz
Huge Clucker
 
Tannz0rz's Avatar
 
Join Date: Dec 2007
Posts: 344
Reputation: 35
Default Oh lawd

Soupz, I gave an attempt at creating a SWAT rope slide thing in single player, and I've overlooked it many times, yet it crashes my server:
Code:
#include <a_samp>

#define FILTERSCRIPT
#define VEH_EXIT 16

#if defined FILTERSCRIPT

new SlideNum[MAX_PLAYERS];
new Slider;

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print("       SWAT Heli        ");
	print("      RRP SWAT Slide      ");
	print("   By: Michael_Sandrino[Tanner] 	 ");
	print("--------------------------------------\n");
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

public OnPlayerConnect(playerid)
{
	SlideNum[playerid] = 0;
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
  if((newkeys & VEH_EXIT) == (VEH_EXIT))
	{
		new StateSlide = GetPlayerState(playerid);
		if(StateSlide == 2)
		{
		  ApplyAnimation(playerid, "SWAT", "swt_wllpk_R_back", 4.0,0,1,1,1,0);
		  SlideNum[playerid] = 1;
		  Slider = SetTimerEx("Slide", 100, 1, "i");
		  return 1;
		}
	}
	return 0;
}

forward Slide(playerid);
public Slide(playerid)
{
	new Float:x, y, z;
	GetPlayerPos(playerid, x, y, z);
	if(SlideNum[playerid] == 1)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 2;
	  return 1;
	}
	if(SlideNum[playerid] == 2)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 3;
	  return 1;
	}
	if(SlideNum[playerid] == 3)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 4;
	  return 1;
	}
	if(SlideNum[playerid] == 4)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 5;
	  return 1;
	}
	if(SlideNum[playerid] == 5)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 6;
	  return 1;
	}
	if(SlideNum[playerid] == 6)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 7;
	  return 1;
	}
	if(SlideNum[playerid] == 7)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 8;
	  return 1;
	}
	if(SlideNum[playerid] == 8)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 9;
	  return 1;
	}
	if(SlideNum[playerid] == 9)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 10;
	  return 1;
	}
	if(SlideNum[playerid] == 10)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 11;
	  return 1;
	}
	if(SlideNum[playerid] == 11)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 12;
	  return 1;
	}
	if(SlideNum[playerid] == 12)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 13;
	  return 1;
	}
	if(SlideNum[playerid] == 13)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 14;
	  return 1;
	}
	if(SlideNum[playerid] == 14)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 15;
	  return 1;
	}
	if(SlideNum[playerid] == 15)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 16;
	  return 1;
	}
	if(SlideNum[playerid] == 16)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 17;
	  return 1;
	}
	if(SlideNum[playerid] == 17)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 18;
	  return 1;
	}
	if(SlideNum[playerid] == 18)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 19;
	  return 1;
	}
	if(SlideNum[playerid] == 19)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 20;
	  return 1;
	}
	if(SlideNum[playerid] == 20)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 21;
	  return 1;
	}
	if(SlideNum[playerid] == 21)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 22;
	  return 1;
	}
	if(SlideNum[playerid] == 22)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 23;
	  return 1;
	}
	if(SlideNum[playerid] == 23)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 24;
	  return 1;
	}
	if(SlideNum[playerid] == 24)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 25;
	  return 1;
	}
	if(SlideNum[playerid] == 25)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 26;
	  return 1;
	}
	if(SlideNum[playerid] == 26)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 27;
	  return 1;
	}
	if(SlideNum[playerid] == 27)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 28;
	  return 1;
	}
	if(SlideNum[playerid] == 28)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 29;
	  return 1;
	}
	if(SlideNum[playerid] == 29)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 30;
	  return 1;
	}
	if(SlideNum[playerid] == 30)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 31;
	  return 1;
	}
	if(SlideNum[playerid] == 31)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 32;
	  return 1;
	}
	if(SlideNum[playerid] == 32)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 33;
	  return 1;
	}
	if(SlideNum[playerid] == 33)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 34;
	  return 1;
	}
	if(SlideNum[playerid] == 34)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 35;
	  return 1;
	}
	if(SlideNum[playerid] == 35)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 36;
	  return 1;
	}
	if(SlideNum[playerid] == 36)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 37;
	  return 1;
	}
	if(SlideNum[playerid] == 37)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 38;
	  return 1;
	}
	if(SlideNum[playerid] == 38)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 39;
	  return 1;
	}
	if(SlideNum[playerid] == 39)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  SlideNum[playerid] = 40;
	  return 1;
	}
	if(SlideNum[playerid] == 40)
	{
	  SetPlayerPos(playerid, x, y, z-0.25);
	  KillTimer(Slider);
	  ClearAnimations(playerid);
	  SlideNum[playerid] = 0;
	  return 1;
	}
	return 1;
}

#endif
As of right now, I have it to where it finds your state (driver) for testing purposes. So when you hit the "F" key, it applies an animation (somewhat like the sliding animation) and it sets a repeating timer which drops your current Z position 10 feet total. The timer seems perfectly fine, unless I'm missing something. It just likes to crash the server. Halpz
__________________
Tannz0rz is offline  
Old 18/04/2009, 05:15 PM   #2
Castle
Huge Clucker
 
Castle's Avatar
 
Join Date: Aug 2008
Posts: 331
Reputation: 0
Default Re: Oh lawd

www.pastebin.com Please, paste the code there.
__________________
Castle is offline  
Old 18/04/2009, 05:16 PM   #3
Joe Staff
High-roller
 
Join Date: Aug 2007
Posts: 2,593
Reputation: 379
Default Re: Oh lawd

You odn't have filterscript defined so none of that is being read anyway. Also your SetTimerEx says that there's an integer to be read but you're not giving one (i.e. SetTimerEx("Slider",100,1,"i",playerid])
Joe Staff is offline  
Old 18/04/2009, 05:21 PM   #4
Tannz0rz
Huge Clucker
 
Tannz0rz's Avatar
 
Join Date: Dec 2007
Posts: 344
Reputation: 35
Default Re: Oh lawd

Oh shit, why didn't I notice that? Let me give it a try.

EDIT: The server still crashes.
__________________
Tannz0rz is offline  
Old 18/04/2009, 05:54 PM   #5
OmeRinG
Big Clucker
 
Join Date: Sep 2008
Posts: 177
Reputation: 0
Default Re: Oh lawd

I kind of recoded it for you and found that the problem was that you called the public Slide before you forwarded it....

so there here is the recoded script and a lot more short..... just for your knowlege i've tried it and when you set the player pos the anim cancels so it looks really bad.....

pawn Code:
#include <a_samp>

new SlideNum[MAX_PLAYERS];
new Slider;
forward Slide(playerid);

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print("       SWAT Heli       ");
    print("      RRP SWAT Slide      ");
    print("  By: Michael_Sandrino[Tanner]    ");
    print("--------------------------------------\n");
    return 1;
}

public OnPlayerConnect(playerid)
{
    SlideNum[playerid] = 0;
    return 1;
}
public OnPlayerExitVehicle(playerid,vehicleid)
{
  ApplyAnimation(playerid, "SWAT", "swt_wllpk_R_back", 4.0,0,1,1,1,0);
  SlideNum[playerid] = 1;
  Slider = SetTimerEx("Slide", 100, 1, "i",playerid);
  return 1;
}


public Slide(playerid)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    switch(SlideNum[playerid])
    {
        case 1..39: {
            SetPlayerPos(playerid, x, y, z-0.25);
        SlideNum[playerid]++;
        }
        case 40: {
            SetPlayerPos(playerid, x, y, z-0.25);
        KillTimer(Slider);
        ClearAnimations(playerid);
        SlideNum[playerid] = 0;
        }
    }
    return 1;
}

Have fun

EDIT:
off-topic, I found out I could make this code only 4 rows lol:
pawn Code:
#include <a_samp>
#pragma tabsize 0
new SlideNum[MAX_PLAYERS],Slider;forward Slide(playerid);public OnFilterScriptInit(){print("\n--------------------------------------");print("       SWAT Heli        ");print("      RRP SWAT Slide      ");print("   By: Michael_Sandrino[Tanner]      ");print("--------------------------------------\n");return 1;}public OnPlayerConnect(playerid){SlideNum[playerid]=0;return 1;}public OnPlayerExitVehicle(playerid,vehicleid){
ApplyAnimation(playerid,"SWAT", "swt_wllpk_R_back",4.0,0,1,1,1,0);SlideNum[playerid]=1;Slider=SetTimerEx("Slide",100,0,"i",playerid);return 1;}public Slide(playerid){new Float:x,Float:y,Float:z;GetPlayerPos(playerid,x,y,z);switch(SlideNum[playerid]){case 1..39:{SetPlayerPos(playerid,x,y,z-0.25);SlideNum[playerid]++;}case 40:{SetPlayerPos(playerid,x,y,z-0.25);KillTimer(Slider);ClearAnimations(playerid);SlideNum[playerid]=0;}}return 1;}
OmeRinG is offline  
Old 18/04/2009, 06:00 PM   #6
ICECOLDKILLAK8
High-roller
 
Join Date: Aug 2008
Posts: 1,154
Reputation: 5
Default Re: Oh lawd

Or even better
pawn Code:
#include <a_samp>

forward Slide(playerid);

new Slider;
new Float:x, Float:y, Float:z;
new SlideNum[MAX_PLAYERS];

public OnFilterScriptInit()
{
  print("\n--------------------------------------");
  print("       SWAT Heli       ");
  print("      RRP SWAT Slide      ");
  print("  By: Michael_Sandrino[Tanner] ");
  print("--------------------------------------\n");
  return 1;
}

public OnPlayerConnect(playerid)
{
  SlideNum[playerid] = 0;
  return 1;
}
public OnPlayerExitVehicle(playerid,vehicleid)
{
  ApplyAnimation(playerid, "SWAT", "swt_wllpk_R_back", 4.0,0,1,1,1,0);
  Slider = SetTimerEx("Slide", 100, 1, "i",playerid);
  return 1;
}


public Slide(playerid)
{
  if(SlideNum[playerid] == 40)
  {
    KillTimer(Slider);
    ClearAnimations(playerid);
    SlideNum[playerid] = 0;
    return 1;
  }
  GetPlayerPos(playerid, x, y, z);
  SetPlayerPos(playerid, x, y, z-0.25);
  SlideNum[playerid]++;
  return 1;
}
BTW if they are higher or lower in the heli then they will end up going through the ground or falling to thier death, There is no accurate way to do anything like this without a height map of San Andreas
__________________
IVMP
ICECOLDKILLAK8 is offline  
Old 18/04/2009, 06:59 PM   #7
Tannz0rz
Huge Clucker
 
Tannz0rz's Avatar
 
Join Date: Dec 2007
Posts: 344
Reputation: 35
Default Re: Oh lawd

Quote:
Originally Posted by JeNkStAX
Or even better
pawn Code:
#include <a_samp>

forward Slide(playerid);

new Slider;
new Float:x, Float:y, Float:z;
new SlideNum[MAX_PLAYERS];

public OnFilterScriptInit()
{
  print("\n--------------------------------------");
  print("       SWAT Heli       ");
  print("      RRP SWAT Slide      ");
  print("  By: Michael_Sandrino[Tanner] ");
  print("--------------------------------------\n");
  return 1;
}

public OnPlayerConnect(playerid)
{
  SlideNum[playerid] = 0;
  return 1;
}
public OnPlayerExitVehicle(playerid,vehicleid)
{
  ApplyAnimation(playerid, "SWAT", "swt_wllpk_R_back", 4.0,0,1,1,1,0);
  Slider = SetTimerEx("Slide", 100, 1, "i",playerid);
  return 1;
}


public Slide(playerid)
{
  if(SlideNum[playerid] == 40)
  {
    KillTimer(Slider);
    ClearAnimations(playerid);
    SlideNum[playerid] = 0;
    return 1;
  }
  GetPlayerPos(playerid, x, y, z);
  SetPlayerPos(playerid, x, y, z-0.25);
  SlideNum[playerid]++;
  return 1;
}
BTW if they are higher or lower in the heli then they will end up going through the ground or falling to thier death, There is no accurate way to do anything like this without a height map of San Andreas
Danke. And I'm aware of that. But with the ordeal with the person falling to their death, it's basically like having a 20 foot rope while your 2,000 feet in the air. So, that's their problem. Falling through the map is a big ordeal though.

MySQL for the win.
__________________
Tannz0rz is offline  
Old 18/04/2009, 07:03 PM   #8
ICECOLDKILLAK8
High-roller
 
Join Date: Aug 2008
Posts: 1,154
Reputation: 5
Default Re: Oh lawd

Quote:
Originally Posted by raydrezack
MySQL for the win.
Whats MYSQL got to do with anything?
__________________
IVMP
ICECOLDKILLAK8 is offline  
Old 18/04/2009, 07:13 PM   #9
ICECOLDKILLAK8
High-roller
 
Join Date: Aug 2008
Posts: 1,154
Reputation: 5
Default Re: Oh lawd

Sorry for the double post

Quote:
Originally Posted by OmeRinG
pawn Code:
#include <a_samp>
#pragma tabsize 0
new SlideNum[MAX_PLAYERS],Slider;forward Slide(playerid);public OnFilterScriptInit(){print("\n--------------------------------------");print("       SWAT Heli       ");print("      RRP SWAT Slide      ");print("  By: Michael_Sandrino[Tanner]    ");print("--------------------------------------\n");return 1;}public OnPlayerConnect(playerid){SlideNum[playerid]=0;return 1;}public OnPlayerExitVehicle(playerid,vehicleid){
ApplyAnimation(playerid,"SWAT", "swt_wllpk_R_back",4.0,0,1,1,1,0);SlideNum[playerid]=1;Slider=SetTimerEx("Slide",100,0,"i",playerid);return 1;}public Slide(playerid){new Float:x,Float:y,Float:z;GetPlayerPos(playerid,x,y,z);switch(SlideNum[playerid]){case 1..39:{SetPlayerPos(playerid,x,y,z-0.25);SlideNum[playerid]++;}case 40:{SetPlayerPos(playerid,x,y,z-0.25);KillTimer(Slider);ClearAnimations(playerid);SlideNum[playerid]=0;}}return 1;}
I cant believe you actually suggested that
__________________
IVMP
ICECOLDKILLAK8 is offline  
Old 18/04/2009, 07:20 PM   #10
OmeRinG
Big Clucker
 
Join Date: Sep 2008
Posts: 177
Reputation: 0
Default Re: Oh lawd

Quote:
Originally Posted by JeNkStAX
Sorry for the double post

Quote:
Originally Posted by OmeRinG
pawn Code:
#include <a_samp>
#pragma tabsize 0
new SlideNum[MAX_PLAYERS],Slider;forward Slide(playerid);public OnFilterScriptInit(){print("\n--------------------------------------");print("       SWAT Heli       ");print("      RRP SWAT Slide      ");print("  By: Michael_Sandrino[Tanner]    ");print("--------------------------------------\n");return 1;}public OnPlayerConnect(playerid){SlideNum[playerid]=0;return 1;}public OnPlayerExitVehicle(playerid,vehicleid){
ApplyAnimation(playerid,"SWAT", "swt_wllpk_R_back",4.0,0,1,1,1,0);SlideNum[playerid]=1;Slider=SetTimerEx("Slide",100,0,"i",playerid);return 1;}public Slide(playerid){new Float:x,Float:y,Float:z;GetPlayerPos(playerid,x,y,z);switch(SlideNum[playerid]){case 1..39:{SetPlayerPos(playerid,x,y,z-0.25);SlideNum[playerid]++;}case 40:{SetPlayerPos(playerid,x,y,z-0.25);KillTimer(Slider);ClearAnimations(playerid);SlideNum[playerid]=0;}}return 1;}
I cant believe you actually suggested that
I didn't I just found out that it's possible and it looks really weird :0
OmeRinG is offline  
 

Thread Tools
Display Modes

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



All times are GMT. The time now is 07:46 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.