Enter the C&C universe on foot as you wage war at ground level among the structures, vehicles and weapons made famous in the series. You assume the role of Havoc, wise-cracking GDI commando who fights and explores from a gripping first-person viewpoint. Battling through exotic indoor and outdoor environments, use your own mix of brute force, stealth and strategy in your mission objectives against the evil Brotherhood of Nod.

Post tutorial Report RSS C&C Renegade Lua Coding

For the guy who wants to host a renegade server and make his own mods.

Posted by on - Advanced Server Side Coding

There are those people out there. Those of you who want to run your own C&C Renegade Server and have some customized characters, spawnable vehicles etc.
Well, this here is your answer.

The real bones for a purchase type of script is:
IF (this was said in F2chat, F3chat, or a PM)
then
IF you are on the right team
AND
you have enough money, then
Do this...

Ill start off simple, with a basic $500 character.
We'll call it !test.

Put the script under this category in luaplugin.lua (1.0) or any of the other .lua files you may have created. (2.0 onward.)

function OnChat(pID, Type, Message)

Then, you put:

if Message == "!test" then

This is the trigger for the script. The script won't fire until someone types this in the chat.
Then, you put what you want for the price and credit requirement:

      		local pos = Get_Position(Get_GameObj(pID))<br />               	if Get_Team(pID) == 1 then<br />                        if Get_Money(pID) < 500 then

This further edits the condition under which the script will fire.
If you don't have the 500 credits, this action will fire:

                       	InputConsole("ppage %d You need 500 credits", pID)

If you have the 500 credits, this will fire:

                	else
                           	Change_Character(Get_GameObj(pID),"Nod_MiniGunner_0")
				Set_Max_Health(Get_GameObj(pID), 75)
				Set_Max_Shield_Strength(Get_GameObj(pID), 75)
				Grant_Powerup(Get_GameObj(pID), "POW_RamjetRifle_Player")
				Grant_Powerup(Get_GameObj(pID), "POW_Railgun_Player")
				Grant_Powerup(Get_GameObj(pID), "POW_VoltAutoRifle_Player")
                        	Set_Money(pID, Get_Money(pID)-500)
                           	InputConsole("msg %s has bought a Test Character for this tutorial.", Get_Player_Name_By_ID(pID))
                   	end

This changes your health, character, and grants you the powerup weapons.
If you aren't on team 1 (GDI) then this condition will fire:

 	else
               		InputConsole("ppage %d You Need to be on GDI", pID)
            	end
        end

The Complete script should look like this (note the indentation)

if Message == "!test" then
      		local pos = Get_Position(Get_GameObj(pID))
               	if Get_Team(pID) == 1 then
                        if Get_Money(pID) < 500 then
                        	InputConsole("ppage %d You need 500 credits", pID)
                	else
                           	Change_Character(Get_GameObj(pID),"Nod_MiniGunner_0")
				Set_Max_Health(Get_GameObj(pID), 750)
				Set_Max_Shield_Strength(Get_GameObj(pID), 750)
				Grant_Powerup(Get_GameObj(pID), "POW_RamjetRifle_Player")
				Grant_Powerup(Get_GameObj(pID), "POW_Railgun_Player")
				Grant_Powerup(Get_GameObj(pID), "POW_VoltAutoRifle_Player")
                        	Set_Money(pID, Get_Money(pID)-500)
                           	InputConsole("msg %s has bought a Test character for this tutorial.", Get_Player_Name_By_ID(pID))
                   	end
            	else
               		InputConsole("ppage %d You Need to be on GDI", pID)
            	end
        end

From here you can edit what you want the chat !trigger to be, how much you want it to cost, what team you want it to work for, what weapons it aquires, and what character it changes to.
Another way, you can get somenone to LOOK like a character, while still retaining the "character" they bought from the PT, is, instead of putting "Change_Character", put this instead. This example is a chicken, but you can put any valid game model, (even the obelisk!)

                         	Set_Model(Get_GameObj(pID),"c_chicken")

For a vehicle, the same proccess applies, except this time, instead of "Change_Character" and "Grant_Powerup", we're going to use "reinf = Create_Object".
The same things apply from the character, so I will post the whole script.
This is for a medium tank.

if Message == "!med" then
		local pos = Get_Position(Get_GameObj(pID))
		if Get_Team(pID) == 1 then
			if Get_Money(pID) < 800 then
				InputConsole("ppage %d You need 800 credits", pID)
			else
				pos:AssignZ(pos:GetZ()+8)
				reinf = Create_Object("CnC_GDI_Medium_Tank", pos)
				if reinf == nil then
					InputConsole("ppage %d Error creating backup / support", pID)
				else
					Set_Money(pID, Get_Money(pID)-0)
				end
			end
		else
			InputConsole("ppage %d Your vehicle is arriving.", pID)
		end
	end

The list of "CnC_" (PT buyable) vehicle presets is:

CnC_GDI_Humm-vee
CnC_GDI_MRLS
CnC_GDI_Orca
CnC_Nod_Buggy
CnC_Nod_Mobile_Artillery
CnC_Nod_Apache
CnC_GDI_Transport
CnC_Nod_Transport
CnC_Nod_Harvester
CnC_GDI_Harvester
CnC_GDI_APC
CnC_GDI_Medium_Tank
CnC_GDI_Mammoth_Tank
CnC_Nod_APC
CnC_Nod_Flame_Tank
CnC_Nod_Light_Tank
CnC_Nod_Stealth_Tank
Nod_Stealth_Tank_Player
Nod_Mobile_Artillery_Dec
CnC_Nod_Recon_Bike

Ill think of more.

Post comment Comments
sla.ro
sla.ro - - 733 comments

nice done. is good for beginners of Lua and Lua Renegade, lol.

PS: me i know those already :P

Reply Good karma Bad karma+2 votes
Guest
Guest - - 690,734 comments

me i need to lear to do mods wen i wil learn i wil do an mod for evry mission 1 nod tank fallow me and kill all enemyes and to have infinite armour was realy great :)

Reply Good karma Bad karma+1 vote
Adriane[Deathscythe]
Adriane[Deathscythe] - - 158 comments

where are this luathings stored ? i want to edit them

Reply Good karma Bad karma+2 votes
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: