SA-MP Forums Archive
Modifying my script a bit... can't seem to get it to work? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Modifying my script a bit... can't seem to get it to work? (/showthread.php?tid=90519)



Modifying my script a bit... can't seem to get it to work? - ThePS3Guy - 08.08.2009

Here is my original filter script that adds nitro to vehicles when you enter them:


#include <a_samp>

public OnFilterScriptInit()
{
print("\n--------------------------------------");
print("Tpg");
print("--------------------------------------\n");
return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
AddVehicleComponent(vehicleid, 1010);
return 1;
}


but when you enter vehicles that can't have nos, it crashes. so i tried changing it to this:



public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
for(new i = 0; i<MAX_PLAYERS; i++)
{
if(!IsPlayerInInvalidNosVehicle(i,GetPlayerVehicle ID(i)))
{
new vehicle = GetPlayerVehicleID(i);
AddVehicleComponent(vehicle, 1010);
}
}
}

IsPlayerInInvalidNosVehicle(playerid,vehicleid)
{
#define MAX_INVALID_NOS_VEHICLES 29

new InvalidNosVehicles[MAX_INVALID_NOS_VEHICLES] =
{
581,523,462,521,463,522,461,448,468,586,
509,481,510,472,473,493,595,484,430,453,
452,446,454,590,569,537,538,570,449
};

vehicleid = GetPlayerVehicleID(playerid);

if(IsPlayerInVehicle(playerid,vehicleid))
{
for(new i = 0; i < MAX_INVALID_NOS_VEHICLES; i++)
{
if(GetVehicleModel(vehicleid) == InvalidNosVehicles[i])
{
return true;
}
}
}
return false;
}



(thanks bert for help with this)but it has seven errors:


C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\fil terscripts\SSnSCars.pwn(13) : warning 235: public function lacks forward declaration (symbol "OnPlayerEnterVehicle")
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\fil terscripts\SSnSCars.pwn(3) : error 017: undefined symbol "MAX_PLAYERS"
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\fil terscripts\SSnSCars.pwn(5) : error 017: undefined symbol "GetPlayerVehicleID"
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\fil terscripts\SSnSCars.pwn(7) : error 017: undefined symbol "GetPlayerVehicleID"
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\fil terscripts\SSnSCars.pwn( : warning 217: loose indentation
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\fil terscripts\SSnSCars.pwn( : error 017: undefined symbol "AddVehicleComponent"
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\fil terscripts\SSnSCars.pwn(7) : warning 204: symbol is assigned a value that is never used: "vehicle"
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\fil terscripts\SSnSCars.pwn(24) : error 017: undefined symbol "GetPlayerVehicleID"
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\fil terscripts\SSnSCars.pwn(26) : error 017: undefined symbol "IsPlayerInVehicle"
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\fil terscripts\SSnSCars.pwn(30) : error 017: undefined symbol "GetVehicleModel"
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\fil terscripts\SSnSCars.pwn(24) : warning 204: symbol is assigned a value that is never used: "vehicleid"
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\fil terscripts\SSnSCars.pwn(13) : warning 203: symbol is never used: "playerid"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


7 Errors.


Please help!


Re: Modifying my script a bit... can't seem to get it to work? - Julian2574 - 08.08.2009

You need to explain for the FS what
Quote:

OnPlayerEnterVehicle

and the rest that gives error to the FS as Forward or use new


Re: Modifying my script a bit... can't seem to get it to work? - ThePS3Guy - 08.08.2009

ok, all i did was put #include <a_samp> at the top and it got rid of all errors.. am trying it out now though



Re: Modifying my script a bit... can't seem to get it to work? - Anwix - 08.08.2009

If that doesnt work try:

http://sa-mp.pastebin.com/d7d6d9e44

untested so, sorry if it doesnt work.


Re: Modifying my script a bit... can't seem to get it to work? - ThePS3Guy - 08.08.2009

Thanks Anwix. That doesn't seem to be working though... Does anyone know why it isn't working? It compiles correctly but it just doesn't work. It doesn't add nos to the vehicle when I enter it.


Re: Modifying my script a bit... can't seem to get it to work? - Julian2574 - 08.08.2009

As i told you the SYMBOL aint used make them USED with forward or new, Maby tomorrow il fix it for you


Re: Modifying my script a bit... can't seem to get it to work? - XPlatform - 08.08.2009

Код:
forward IsNosVehicle(vehicleid);

public IsNosVehicle(vehicleid)
{
  #define MAX_INVALID_NOS_VEHICLES 29
  new InvalidNosVehicles[MAX_INVALID_NOS_VEHICLES] = {
  581,523,462,521,463,522,461,448,468,586,
  509,481,510,472,473,493,595,484,430,453,
  452,446,454,590,569,537,538,570,449
  };
  for(new i = 0; i < MAX_INVALID_NOS_VEHICLES; i++)
  {
    if(GetVehicleModel(vehicleid) == InvalidNosVehicles[i])
    {
      return 0;
    }
  }
  return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  if(IsNosVehicle(vehicleid) == 1)
  {
    AddVehicleComponent(vehicleid, 1010);
  }
}
Try that, it's untested though!

Hope this helps!