[HELP]Why Code Not Compiled
#1

Код:
#include <a_samp>
#include "a_players"
#include "a_objects"

#if defined filterscripts

public OnFilterScriptInit()
{
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

#else

main()
{
	print("bombaci\n");
}

#endif

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(newkeys == KEY_NO)
	{
	  switch(Vehicle[vehicleid])
	    {
		   case 1: 460;
	    }
	  new Float:VehicleRotX, Float:VehicleRotY, Float:VehicleRotZ;
	  GetPlayerPos(playerid, x, y, z);
	  if(VehicleRotX == VehicleRotY)
	  new torpedo = CreateObject(3790, x, y, z, rX, rY, rZ, DrawDistance)
	  {
		MoveObject(torpedo, x + 15, y + 15, z, 250.0, RotX, RotY, RotZ);
		DestroyObject(torpedo);
      }
      else
      if(VehicleRotX = 5.0 && VehicleRotY = 0.0)
      {
        MoveObject(torpedo, x + 15, y, z, 250.0, RotX, RotY, RotZ);
		DestroyObject(torpedo);
      }
      else
      if(VehicleRotX = 0.0 && VehicleRotY = 5.0)
      {
        MoveObject(torpedo, x + 15, y, z, 250.0, RotX, RotY, RotZ);
		DestroyObject(torpedo);
      }
      if(DestroyObject(torpedo))
      {
		CreateExplosion(x, y, z, 7, 15);
	}
	return 1;
}
Why?

Код:
C:\SAMP\filterscripts\torpedo.pwn(34) : error 017: undefined symbol "Vehicle"
C:\SAMP\filterscripts\torpedo.pwn(34) : error 029: invalid expression, assumed zero
C:\SAMP\filterscripts\torpedo.pwn(34) : error 029: invalid expression, assumed zero
C:\SAMP\filterscripts\torpedo.pwn(34) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#2

You need to declare a variable called Vehicle.

Код:
new Vehicle[MAX_VEHICLES];
Reply
#3

Thats because you are doing almost everything wrong, lets start from the beginning
pawn Код:
switch(Vehicle[vehicleid])
    {
        case 1: 460;
    }
what actually is this? are you trying to get players vehicle model? if yes thats not how you do it...
this is the correct way

pawn Код:
new vehicleid = GetPlayerVehicleID(playerid); //Storing Vehicle ID of Player in "vehicleid"
    new model = GetVehicleModel(vehicleid); //Storing Vehicle Model of Player in "vehicleid"
    if(modelid == 460) //if vehicle model is skimmer plane continue your code here
    {
    }
ok so we are done above lets get to the next mistake of yours
pawn Код:
new Float:VehicleRotX, Float:VehicleRotY, Float:VehicleRotZ;
what you did here, is that you created arrays but didnt store anything inside so for getting Vehicle Rotation here its how you do it:-

pawn Код:
stock GetVehicleRotation(vehicleid,&Float:x,&Float:y,&Float:z) //Credits: Stepashka
{
    new Float:quat_w,Float:quat_x,Float:quat_y,Float:quat_z;
    GetVehicleRotationQuat(vehicleid,quat_w,quat_x,quat_y,quat_z);
    x = atan2(2*((quat_x*quat_y)+(quat_w+quat_z)),(quat_w*quat_w)+(quat_x*quat_x)-(quat_y*quat_y)-(quat_z*quat_z));
    y = atan2(2*((quat_y*quat_z)+(quat_w*quat_x)),(quat_w*quat_w)-(quat_x*quat_x)-(quat_y*quat_y)+(quat_z*quat_z));
    z = asin(-2*((quat_x*quat_z)+(quat_w*quat_y)));
    return 1;
}

new Float:VehicleRotX, Float:VehicleRotY, Float:VehicleRotZ;
GetVehicleRotation(vehicleid, VehicleRotX, VehicleRotY, VehicleRotZ);
moving towards third mistake
pawn Код:
GetPlayerPos(playerid, x, y, z);
you should consider using
pawn Код:
new Float:VehX, Float:VehY, Float:VehZ;
GetVehiclePos(vehicleid, VehX, VehY, VehZ); //Storing vehicle position inside Vehx, vehy and vehz
moving toward the last part:
pawn Код:
if(VehicleRotX == VehicleRotY)
      new torpedo = CreateObject(3790, x, y, z, rX, rY, rZ, DrawDistance)
      {
        MoveObject(torpedo, x + 15, y + 15, z, 250.0, RotX, RotY, RotZ);
        DestroyObject(torpedo);
      }
      else
      if(VehicleRotX = 5.0 && VehicleRotY = 0.0)
      {
        MoveObject(torpedo, x + 15, y, z, 250.0, RotX, RotY, RotZ);
        DestroyObject(torpedo);
      }
      else
      if(VehicleRotX = 0.0 && VehicleRotY = 5.0)
      {
        MoveObject(torpedo, x + 15, y, z, 250.0, RotX, RotY, RotZ);
        DestroyObject(torpedo);
      }
      if(DestroyObject(torpedo))
      {
        CreateExplosion(x, y, z, 7, 15);
    }
    return 1;
}
ok what you did here is pretty much everything is wrong

By your code i figured that you are creating missile system, so here is how you do it
pawn Код:
if(VehicleRotX == VehicleRotY) //when x and y rotation are same
{
    new objectid = CreateObject(3790, VehX, VehY, VehZ, VehicleRotX, VehicleRotY, VehicleRotZ); //creating object and storing id in objectid so we can destroy it later
    MoveObject(objectid, VehX + 15.0,, VehY + 15.0, VehZ, 250.0, VehicleRotX, VehicleRotY, VehicleRotZ); //moving object we just created
    SetTimerEx("Missile", 5000, false, "i", objectid); //Starting a timer so we can delete the object and create after 5 seconds, keep in mind timer uses millisecond, so 5000 = 5 seconds
}
else if(VehicleRotX = 5.0 && VehicleRotY = 0.0) //when rotation x is 5.0 and y rotation is 0.0
{
    new objectid = CreateObject(3790, VehX, VehY, VehZ, VehicleRotX, VehicleRotY, VehicleRotZ); //creating object and storing id in objectid so we can destroy it later
    MoveObject(objectid, VehX + 15, VehY, VehZ, 250.0, VehicleRotX, VehicleRotY, VehicleRotZ); //moving object we just created
    SetTimerEx("Missile", 5000, false, "i", objectid); //Starting a timer so we can delete the object and create after 5 seconds, keep in mind timer uses millisecond, so 5000 = 5 seconds
}
else if(VehicleRotX = 0.0 && VehicleRotY = 5.0) //when rotation x is 0.0 and y rotation is 5.0
{
    new objectid = CreateObject(3790, VehX, VehY, VehZ, VehicleRotX, VehicleRotY, VehicleRotZ); //creating object and storing id in objectid so we can destroy it later
    MoveObject(objectid, VehX + 15, VehY, VehZ, 250.0, VehicleRotX, VehicleRotY, VehicleRotZ); //moving object we just created
    SetTimerEx("Missile", 5000, false, "i", objectid); //Starting a timer so we can delete the object and create after 5 seconds, keep in mind timer uses millisecond, so 5000 = 5 seconds
}

forward Missile(objectid);
public Missile(objectid) //ok this is where we put what happens after 5 seconds
{
    new Float:x, Float:y, Float:z; //creating float array
    GetObjectPos(objectid, x, y, z); //getting objects position
    CreateExplosion(x, y, z, 7, 10.0); //creating explosion on oject
    DestroyObject(objectid); //destroying the object
}

and this is how your code should look like
pawn Код:
#include <a_samp>
#include <a_players>
#include <a_objects>

#if defined filterscripts

public OnFilterScriptInit()
{
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("bombaci\n");
}

#endif

stock GetVehicleRotation(vehicleid,&Float:x,&Float:y,&Float:z) //Credits: Stepashka
{
    new Float:quat_w,Float:quat_x,Float:quat_y,Float:quat_z;
    GetVehicleRotationQuat(vehicleid,quat_w,quat_x,quat_y,quat_z);
    x = atan2(2*((quat_x*quat_y)+(quat_w+quat_z)),(quat_w*quat_w)+(quat_x*quat_x)-(quat_y*quat_y)-(quat_z*quat_z));
    y = atan2(2*((quat_y*quat_z)+(quat_w*quat_x)),(quat_w*quat_w)-(quat_x*quat_x)-(quat_y*quat_y)+(quat_z*quat_z));
    z = asin(-2*((quat_x*quat_z)+(quat_w*quat_y)));
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_NO) //when you press key n
    {
        new vehicleid = GetPlayerVehicleID(playerid); //Storing Vehicle ID of Player in "vehicleid"
        new model = GetVehicleModel(vehicleid); //Storing Vehicle Model of Player in "vehicleid"
        if(model == 460) //if vehicle model is skimmer plane continue your code here
        {
            new Float:VehicleRotX, Float:VehicleRotY, Float:VehicleRotZ; //Creating variables
            GetVehicleRotation(vehicleid, VehicleRotX, VehicleRotY, VehicleRotZ); //storing rotation in the variables we just created
            new Float:VehX, Float:VehY, Float:VehZ; //Creating variables
            GetVehiclePos(vehicleid, VehX, VehY, VehZ); //Storing vehicle position inside Vehx, vehy and vehz
            if(VehicleRotX == VehicleRotY) //when x and y rotation are same
            {
                new objectid = CreateObject(3790, VehX, VehY, VehZ, VehicleRotX, VehicleRotY, VehicleRotZ); //creating object and storing id in objectid so we can destroy it later
                MoveObject(objectid, VehX + 15.0, VehY + 15.0, VehZ, 250.0, VehicleRotX, VehicleRotY, VehicleRotZ); //moving object we just created
                SetTimerEx("Missile", 5000, false, "i", objectid); //Starting a timer so we can delete the object and create after 5 seconds, keep in mind timer uses millisecond, so 5000 = 5 seconds
            }
            else if(VehicleRotX == 5.0 && VehicleRotY == 0.0) //when rotation x is 5.0 and y rotation is 0.0
            {
                new objectid = CreateObject(3790, VehX, VehY, VehZ, VehicleRotX, VehicleRotY, VehicleRotZ); //creating object and storing id in objectid so we can destroy it later
                MoveObject(objectid, VehX + 15.0, VehY, VehZ, 250.0, VehicleRotX, VehicleRotY, VehicleRotZ); //moving object we just created
                SetTimerEx("Missile", 5000, false, "i", objectid); //Starting a timer so we can delete the object and create after 5 seconds, keep in mind timer uses millisecond, so 5000 = 5 seconds
            }
            else if(VehicleRotX == 0.0 && VehicleRotY == 5.0) //when rotation x is 0.0 and y rotation is 5.0
            {
                new objectid = CreateObject(3790, VehX, VehY, VehZ, VehicleRotX, VehicleRotY, VehicleRotZ); //creating object and storing id in objectid so we can destroy it later
                MoveObject(objectid, VehX + 15.0, VehY, VehZ, 250.0, VehicleRotX, VehicleRotY, VehicleRotZ); //moving object we just created
                SetTimerEx("Missile", 5000, false, "i", objectid); //Starting a timer so we can delete the object and create after 5 seconds, keep in mind timer uses millisecond, so 5000 = 5 seconds
            }
        }
    }
    return 1;
}

forward Missile(objectid);
public Missile(objectid) //ok this is where we put what happens after 5 seconds
{
    new Float:x, Float:y, Float:z; //creating float array
    GetObjectPos(objectid, x, y, z); //getting objects position
    CreateExplosion(x, y, z, 7, 10.0); //creating explosion on oject
    DestroyObject(objectid); //destroying the object
}

didnt test but it should work
Reply
#4

PHP код:
if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 460)return 1
Why want scripters always to create variables
Reply
#5

I actually do that but i created variables to explain him
Reply
#6

Okey helps for thanks.
Reply
#7

Quote:
Originally Posted by ReD_HunTeR
Посмотреть сообщение
Thats because you are doing almost everything wrong, lets start from the beginning
pawn Код:
switch(Vehicle[vehicleid])
    {
        case 1: 460;
    }
what actually is this? are you trying to get players vehicle model? if yes thats not how you do it...
this is the correct way

pawn Код:
new vehicleid = GetPlayerVehicleID(playerid); //Storing Vehicle ID of Player in "vehicleid"
    new model = GetVehicleModel(vehicleid); //Storing Vehicle Model of Player in "vehicleid"
    if(modelid == 460) //if vehicle model is skimmer plane continue your code here
    {
    }
ok so we are done above lets get to the next mistake of yours
pawn Код:
new Float:VehicleRotX, Float:VehicleRotY, Float:VehicleRotZ;
what you did here, is that you created arrays but didnt store anything inside so for getting Vehicle Rotation here its how you do it:-

pawn Код:
stock GetVehicleRotation(vehicleid,&Float:x,&Float:y,&Float:z) //Credits: Stepashka
{
    new Float:quat_w,Float:quat_x,Float:quat_y,Float:quat_z;
    GetVehicleRotationQuat(vehicleid,quat_w,quat_x,quat_y,quat_z);
    x = atan2(2*((quat_x*quat_y)+(quat_w+quat_z)),(quat_w*quat_w)+(quat_x*quat_x)-(quat_y*quat_y)-(quat_z*quat_z));
    y = atan2(2*((quat_y*quat_z)+(quat_w*quat_x)),(quat_w*quat_w)-(quat_x*quat_x)-(quat_y*quat_y)+(quat_z*quat_z));
    z = asin(-2*((quat_x*quat_z)+(quat_w*quat_y)));
    return 1;
}

new Float:VehicleRotX, Float:VehicleRotY, Float:VehicleRotZ;
GetVehicleRotation(vehicleid, VehicleRotX, VehicleRotY, VehicleRotZ);
moving towards third mistake
pawn Код:
GetPlayerPos(playerid, x, y, z);
you should consider using
pawn Код:
new Float:VehX, Float:VehY, Float:VehZ;
GetVehiclePos(vehicleid, VehX, VehY, VehZ); //Storing vehicle position inside Vehx, vehy and vehz
moving toward the last part:
pawn Код:
if(VehicleRotX == VehicleRotY)
      new torpedo = CreateObject(3790, x, y, z, rX, rY, rZ, DrawDistance)
      {
        MoveObject(torpedo, x + 15, y + 15, z, 250.0, RotX, RotY, RotZ);
        DestroyObject(torpedo);
      }
      else
      if(VehicleRotX = 5.0 && VehicleRotY = 0.0)
      {
        MoveObject(torpedo, x + 15, y, z, 250.0, RotX, RotY, RotZ);
        DestroyObject(torpedo);
      }
      else
      if(VehicleRotX = 0.0 && VehicleRotY = 5.0)
      {
        MoveObject(torpedo, x + 15, y, z, 250.0, RotX, RotY, RotZ);
        DestroyObject(torpedo);
      }
      if(DestroyObject(torpedo))
      {
        CreateExplosion(x, y, z, 7, 15);
    }
    return 1;
}
ok what you did here is pretty much everything is wrong

By your code i figured that you are creating missile system, so here is how you do it
pawn Код:
if(VehicleRotX == VehicleRotY) //when x and y rotation are same
{
    new objectid = CreateObject(3790, VehX, VehY, VehZ, VehicleRotX, VehicleRotY, VehicleRotZ); //creating object and storing id in objectid so we can destroy it later
    MoveObject(objectid, VehX + 15.0,, VehY + 15.0, VehZ, 250.0, VehicleRotX, VehicleRotY, VehicleRotZ); //moving object we just created
    SetTimerEx("Missile", 5000, false, "i", objectid); //Starting a timer so we can delete the object and create after 5 seconds, keep in mind timer uses millisecond, so 5000 = 5 seconds
}
else if(VehicleRotX = 5.0 && VehicleRotY = 0.0) //when rotation x is 5.0 and y rotation is 0.0
{
    new objectid = CreateObject(3790, VehX, VehY, VehZ, VehicleRotX, VehicleRotY, VehicleRotZ); //creating object and storing id in objectid so we can destroy it later
    MoveObject(objectid, VehX + 15, VehY, VehZ, 250.0, VehicleRotX, VehicleRotY, VehicleRotZ); //moving object we just created
    SetTimerEx("Missile", 5000, false, "i", objectid); //Starting a timer so we can delete the object and create after 5 seconds, keep in mind timer uses millisecond, so 5000 = 5 seconds
}
else if(VehicleRotX = 0.0 && VehicleRotY = 5.0) //when rotation x is 0.0 and y rotation is 5.0
{
    new objectid = CreateObject(3790, VehX, VehY, VehZ, VehicleRotX, VehicleRotY, VehicleRotZ); //creating object and storing id in objectid so we can destroy it later
    MoveObject(objectid, VehX + 15, VehY, VehZ, 250.0, VehicleRotX, VehicleRotY, VehicleRotZ); //moving object we just created
    SetTimerEx("Missile", 5000, false, "i", objectid); //Starting a timer so we can delete the object and create after 5 seconds, keep in mind timer uses millisecond, so 5000 = 5 seconds
}

forward Missile(objectid);
public Missile(objectid) //ok this is where we put what happens after 5 seconds
{
    new Float:x, Float:y, Float:z; //creating float array
    GetObjectPos(objectid, x, y, z); //getting objects position
    CreateExplosion(x, y, z, 7, 10.0); //creating explosion on oject
    DestroyObject(objectid); //destroying the object
}

and this is how your code should look like
pawn Код:
#include <a_samp>
#include <a_players>
#include <a_objects>

#if defined filterscripts

public OnFilterScriptInit()
{
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("bombaci\n");
}

#endif

stock GetVehicleRotation(vehicleid,&Float:x,&Float:y,&Float:z) //Credits: Stepashka
{
    new Float:quat_w,Float:quat_x,Float:quat_y,Float:quat_z;
    GetVehicleRotationQuat(vehicleid,quat_w,quat_x,quat_y,quat_z);
    x = atan2(2*((quat_x*quat_y)+(quat_w+quat_z)),(quat_w*quat_w)+(quat_x*quat_x)-(quat_y*quat_y)-(quat_z*quat_z));
    y = atan2(2*((quat_y*quat_z)+(quat_w*quat_x)),(quat_w*quat_w)-(quat_x*quat_x)-(quat_y*quat_y)+(quat_z*quat_z));
    z = asin(-2*((quat_x*quat_z)+(quat_w*quat_y)));
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_NO) //when you press key n
    {
        new vehicleid = GetPlayerVehicleID(playerid); //Storing Vehicle ID of Player in "vehicleid"
        new model = GetVehicleModel(vehicleid); //Storing Vehicle Model of Player in "vehicleid"
        if(model == 460) //if vehicle model is skimmer plane continue your code here
        {
            new Float:VehicleRotX, Float:VehicleRotY, Float:VehicleRotZ; //Creating variables
            GetVehicleRotation(vehicleid, VehicleRotX, VehicleRotY, VehicleRotZ); //storing rotation in the variables we just created
            new Float:VehX, Float:VehY, Float:VehZ; //Creating variables
            GetVehiclePos(vehicleid, VehX, VehY, VehZ); //Storing vehicle position inside Vehx, vehy and vehz
            if(VehicleRotX == VehicleRotY) //when x and y rotation are same
            {
                new objectid = CreateObject(3790, VehX, VehY, VehZ, VehicleRotX, VehicleRotY, VehicleRotZ); //creating object and storing id in objectid so we can destroy it later
                MoveObject(objectid, VehX + 15.0, VehY + 15.0, VehZ, 250.0, VehicleRotX, VehicleRotY, VehicleRotZ); //moving object we just created
                SetTimerEx("Missile", 5000, false, "i", objectid); //Starting a timer so we can delete the object and create after 5 seconds, keep in mind timer uses millisecond, so 5000 = 5 seconds
            }
            else if(VehicleRotX == 5.0 && VehicleRotY == 0.0) //when rotation x is 5.0 and y rotation is 0.0
            {
                new objectid = CreateObject(3790, VehX, VehY, VehZ, VehicleRotX, VehicleRotY, VehicleRotZ); //creating object and storing id in objectid so we can destroy it later
                MoveObject(objectid, VehX + 15.0, VehY, VehZ, 250.0, VehicleRotX, VehicleRotY, VehicleRotZ); //moving object we just created
                SetTimerEx("Missile", 5000, false, "i", objectid); //Starting a timer so we can delete the object and create after 5 seconds, keep in mind timer uses millisecond, so 5000 = 5 seconds
            }
            else if(VehicleRotX == 0.0 && VehicleRotY == 5.0) //when rotation x is 0.0 and y rotation is 5.0
            {
                new objectid = CreateObject(3790, VehX, VehY, VehZ, VehicleRotX, VehicleRotY, VehicleRotZ); //creating object and storing id in objectid so we can destroy it later
                MoveObject(objectid, VehX + 15.0, VehY, VehZ, 250.0, VehicleRotX, VehicleRotY, VehicleRotZ); //moving object we just created
                SetTimerEx("Missile", 5000, false, "i", objectid); //Starting a timer so we can delete the object and create after 5 seconds, keep in mind timer uses millisecond, so 5000 = 5 seconds
            }
        }
    }
    return 1;
}

forward Missile(objectid);
public Missile(objectid) //ok this is where we put what happens after 5 seconds
{
    new Float:x, Float:y, Float:z; //creating float array
    GetObjectPos(objectid, x, y, z); //getting objects position
    CreateExplosion(x, y, z, 7, 10.0); //creating explosion on oject
    DestroyObject(objectid); //destroying the object
}

didnt test but it should work
I am but mind not missile system.I am only create mind a torpedo system but it work.I am sorry bad english.Thank you
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)