SA-MP Forums Archive
[Tutorial] [TuT] Making a real 'God car' - 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: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] [TuT] Making a real 'God car' (/showthread.php?tid=152376)

Pages: 1 2


[TuT] Making a real 'God car' - Antonio [G-RP] - 03.06.2010

I've seen the attempts, and I'm not sure whether they are what I am going to attempt to do today, but here it goes. Basicly, the function of this 'god car' is to be a car that never
gets damaged. And by that, I mean as in vehicle HP, not looks


Step 1:

At the top of the script, where you keep defines, and forwards, place these lines:
pawn Код:
forward GodCarFix();
new IsGodCar[MAX_VEHICLES];

// the 2 defines below are if you DONT already have them, do NOT add them if you already have them
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_RED 0xAA3333AA
Step 2:

You need to make a command to make the vehicle a god car. Under 'OnPlayerCommandText' add this:
pawn Код:
if(strcmp(cmd, "/setgodcar", true) == 0)
{
if(IsPlayerAdmin(playerid))
{
new string[256];
carid = GetPlayerVehicleID(playerid);
IsGodCar[carid] = 1;
format(string, sizeof(string), "You have made vehicle id %d a god car!", carid);
SendClientMessage(playerid, COLOR_YELLOW, string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, "You must be an RCON admin to use this command!");
}
return 1;
}
Step 3:

Under 'OnGameModeInit' you need to create a loop that fixes the vehicle (hence, 'God Car')
pawn Код:
SetTimer("GodCarFix", 1000, 1);
Let me break this down. The timer is running a loop, or a function called "GodCarFix", and the 1000 means that its every 1 second, because it is in milliseconds. The '1' at the end shows that it is repeating.

Step 4:

Finally you need to add the function that atcually fixes the car. You can add this anywhere OUTSIDE another function, but it is easiest to just add it at the end of the script..
pawn Код:
public GodCarFix()
{
for(new v=0;v<MAX_VEHICLES;v++)
{
if(IsGodCar[v] == 1)
{
SetVehicleHealth(v, 1000);
}
}
return 1;
}
And thats basicly it! If you have any questions, feel free to reply, or add my msn at fpsgamerz@hotmail.com




Re: [TuT] Making a real 'God car' - mprofitt - 03.06.2010

Quote:
Originally Posted by Antonio (eternalrp.webatu.com)
I've seen the attempts, and I'm not sure whether they are what I am going to attempt to do today, but here it goes. Basicly, the function of this 'god car' is to be a car that never
gets damaged. And by that, I mean as in vehicle HP, not looks


Step 1:

At the top of the script, where you keep defines, and forwards, place these lines:
pawn Код:
forward GodCarFix();
new IsGodCar[MAX_VEHICLES];

// the 2 defines below are if you DONT already have them, do NOT add them if you already have them
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_RED 0xAA3333AA
Step 2:

You need to make a command to make the vehicle a god car. Under 'OnPlayerCommandText' add this:
pawn Код:
if(strcmp(cmd, "/setgodcar", true) == 0)
{
if(IsPlayerAdmin(playerid))
{
new string[256];
carid = GetPlayerVehicleID(playerid);
IsGodCar[carid] = 1;
format(string, sizeof(string), "You have made vehicle id %d a god car!", carid);
SendClientMessage(playerid, COLOR_YELLOW, string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, "You must be an RCON admin to use this command!");
}
return 1;
}
Step 3:

Under 'OnGameModeInit' you need to create a loop that fixes the vehicle (hence, 'God Car')
pawn Код:
SetTimer("GodCarFix", 1000, 1);
Let me break this down. The timer is running a loop, or a function called "GodCarFix", and the 1000 means that its every 1 second, because it is in milliseconds. The '1' at the end shows that it is repeating.

Step 4:

Finally you need to add the function that atcually fixes the car. You can add this anywhere OUTSIDE another function, but it is easiest to just add it at the end of the script..
pawn Код:
public GodCarFix()
{
for(new v=0;v<MAX_VEHICLES;v++)
{
if(IsGodCar[v] == 1)
{
SetVehicleHealth(v, 1000);
}
}
return 1;
}
And thats basicly it! If you have any questions, feel free to reply, or add my msn at fpsgamerz@hotmail.com

Can you repeat that? I am a little confused. What if I want a clover to be a God car? Can I do that?

I pasted your filter script into the plugins directory and called it GodCar.amx. It doesn't seem to work. Please explain more.


Re: [TuT] Making a real 'God car' - Antonio [G-RP] - 03.06.2010

This isn't a filterscript, its made to add into your GM. You can make any car you want a God Car, all you need to do use the command.


Re: [TuT] Making a real 'God car' - [HiC]TheKiller - 04.06.2010

Identation is your friend .


Re: [TuT] Making a real 'God car' - Antonio [G-RP] - 04.06.2010

I've never indented, nor did I learn. If anybody wishes to teach me the fast way to indent, thanks


Re: [TuT] Making a real 'God car' - MWF2 - 04.06.2010

Quote:
Originally Posted by Antonio (eternalrp.webatu.com)
I've never indented, nor did I learn. If anybody wishes to teach me the fast way to indent, thanks
DracoBlue is your friend


http://dracoblue.net/tidy/pawn/


Re: [TuT] Making a real 'God car' - Joe Staff - 04.06.2010

You can just use OnVehicleDamageStatusUpdate(vehicleid, playerid) instead of a timer

pawn Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
  if(vehicleid==MyVehicle)RepairVehicle(vehicleid);
  return 1;
}



Re: [TuT] Making a real 'God car' - Antonio [G-RP] - 04.06.2010

Ah I love you joe, you got MSN?


Re: [TuT] Making a real 'God car' - cessil - 04.06.2010

why have a 2000 array? I doubt you'd make them all god cars, I'd use PVars so that when the player disconnects the car is no longer godly.

also I'd do what joe said, but when the car flips it'll still decrease and it'll eventually blow up, for this I'd put in
Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
  if(vehicleid==MyVehicle)RepairVehicle(vehicleid);
  new Float:health;
  GetVehicleHealth(vehicleid,health);
  if(floatcmp(300.0,health) == 1)
  {
    new Float:pR;
    GetVehicleZAngle(GetPlayerVehicleID(id), pR);
    SetVehicleZAngle(GetPlayerVehicleID(id), pR);
  }
  return 1;
}



Re: [TuT] Making a real 'God car' - Antonio [G-RP] - 04.06.2010

Ok ok im sorry! My tutorial is shat! lol


Re: [TuT] Making a real 'God car' - Ozwell_Spencer - 04.06.2010

Code:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
  if(vehicleid==MyVehicle)RepairVehicle(vehicleid);
  new Float:health;
  GetVehicleHealth(vehicleid,health);
  if(floatcmp(300.0,health) == 1)
  {
    new Float:pR;
    GetVehicleZAngle(GetPlayerVehicleID(id), pR);
    SetVehicleZAngle(GetPlayerVehicleID(id), pR);
  }
  return 1;
}
pawn Code:
C:\DOCUME~1\JANDRE~1\Desktop\GTASA-~1\GAMEMO~1\zombies.pwn(254) : error 017: undefined symbol "MyVehicle"
C:\DOCUME~1\JANDRE~1\Desktop\GTASA-~1\GAMEMO~1\zombies.pwn(260) : error 017: undefined symbol "id"
C:\DOCUME~1\JANDRE~1\Desktop\GTASA-~1\GAMEMO~1\zombies.pwn(261) : error 017: undefined symbol "id"
I get these errors when I use that method.
[/quote]


Re: [TuT] Making a real 'God car' - Antonio [G-RP] - 04.06.2010

change 'MyVehicle' to 'IsGodCar' and the 'id' to 'playerid'


Re: [TuT] Making a real 'God car' - Ozwell_Spencer - 04.06.2010

I am using the original method for ADMINS ONLY, and I keep getting these errors:

pawn Code:
C:\DOCUME~1\JANDRE~1\Desktop\GTASA-~1\GAMEMO~1\zombies.pwn(100) : error 017: undefined symbol "cmd"
C:\DOCUME~1\JANDRE~1\Desktop\GTASA-~1\GAMEMO~1\zombies.pwn(104) : error 017: undefined symbol "carid"
C:\DOCUME~1\JANDRE~1\Desktop\GTASA-~1\GAMEMO~1\zombies.pwn(105) : error 017: undefined symbol "carid"
C:\DOCUME~1\JANDRE~1\Desktop\GTASA-~1\GAMEMO~1\zombies.pwn(106) : error 017: undefined symbol "carid"
C:\DOCUME~1\JANDRE~1\Desktop\GTASA-~1\GAMEMO~1\zombies.pwn(115) : warning 209: function "OnPlayerCommandText" should return a value



Re: [TuT] Making a real 'God car' - Ozwell_Spencer - 04.06.2010

Do you guys know how I can fix that?


Re: [TuT] Making a real 'God car' - Antonio [G-RP] - 04.06.2010

Send me your 'OnPlayerCommandText' on http://pastebin.com .. ill fix it for you.


Re: [TuT] Making a real 'God car' - Ozwell_Spencer - 04.06.2010

http://pastebin.com/bZPbcyv8

That's it, it'd be great if you could help me with it.


Re: [TuT] Making a real 'God car' - Antonio [G-RP] - 04.06.2010

http://pastebin.com/XhsxLfmM

Try that


Re: [TuT] Making a real 'God car' - Ozwell_Spencer - 04.06.2010

How do I copy it without it having the line number when I post it in Pawno?


Re: [TuT] Making a real 'God car' - Ozwell_Spencer - 04.06.2010

Never mind, I got it, but it's still saying:
pawn Code:
C:\DOCUME~1\JANDRE~1\Desktop\GTASA-~1\GAMEMO~1\zombies.pwn(104) : error 017: undefined symbol "carid"
C:\DOCUME~1\JANDRE~1\Desktop\GTASA-~1\GAMEMO~1\zombies.pwn(105) : error 017: undefined symbol "carid"
C:\DOCUME~1\JANDRE~1\Desktop\GTASA-~1\GAMEMO~1\zombies.pwn(106) : error 017: undefined symbol "carid"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase



Re: [TuT] Making a real 'God car' - Antonio [G-RP] - 04.06.2010

My mistake.. THIS compiles

http://pastebin.com/jrdPkTqG