Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Scripting help
Scripting help [message #436628] Wed, 15 September 2010 14:59 Go to next message
wubwub is currently offline  wubwub
Messages: 142
Registered: May 2009
Location: Ontario
Karma: 0
Recruit


I want to attach a script to both tiberium refinery's to edit credit rate.

function OnLevelLoaded(Preset)
Attach_Script(Get_GameObj(What do i put in here??), "JFW_Tiberium_Refinery", "5,01.00")
Attach_Script(Get_GameObj(), "JFW_Tiberium_Refinery", "5,01.00")

end


This is obviously incorrect but what do i put in (Get_Gameobj(What do i put in here?), ??
And i also want to attach a script to GDI and Nod harvester, is it still "Get_GameObj"?

Another thing, the preset for the obby gun (Weapon_obelisk) is not working, nor is the preset for the strong repair gun,

Any help to get those working?


When renegade goes Wub, it never goes back

(or at least until I re-install renegade anyways)

http://i266.photobucket.com/albums/ii272/ZaydenX/Walrus-Sig.jpg

[Updated on: Wed, 15 September 2010 15:19]

Report message to a moderator

Re: Scripting help [message #436638 is a reply to message #436628] Thu, 16 September 2010 00:47 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
I am not home at the moment so I can't get you the exact names but if you look in engine_game.h you should find functions like;

GetRefineryByTeam
GetHarvesterByTeam

etc...


http://steamsignature.com/card/1/76561197975867233.png
Re: Scripting help [message #436646 is a reply to message #436628] Thu, 16 September 2010 05:11 Go to previous messageGo to next message
Sladewill is currently offline  Sladewill
Messages: 291
Registered: January 2009
Location: United Kingdom
Karma: 0
Recruit

There is Get_Refinery(team); i believe

FT-Owners - Sladewill,Snazy2007,Willdy
http://FT-Gaming.com for more info...
Re: Scripting help [message #436648 is a reply to message #436628] Thu, 16 September 2010 06:45 Go to previous messageGo to next message
reborn is currently offline  reborn
Messages: 3231
Registered: September 2004
Location: uk - london
Karma: 0
General (3 Stars)
You'll need a way to actually call the function you're making to attach that script...

For example, in SSGM there is the level_loaded event, which looks like this:

void Level_Loaded() {
	strncpy(Data->CurrMap,The_Game()->MapName,29);
	Settings->Load();

	Attach_Script_All_Buildings_Team(2,"MDB_SSGM_Building","",true);
	Attach_Script_All_Turrets_Team(2,"MDB_SSGM_Base_Defense","",true);

	if (Settings->EnableNewCrates) {
		Crate_Level_Loaded();
	}
	if (Settings->Gamelog) {
		Gamelog_Level_Loaded();
	}
	if (Settings->GameMode == 2) {
		CTF_Level_Loaded();
	}

	if (Settings->LogPlayerPurchase) {
		Data->PlayerPurchaseHookID = AddCharacterPurchaseMonHook(SSGM_Purchase_Hook,0);
	}
	if (Settings->LogPowerupPurchase) {
		Data->PowerupPurchaseHookID = AddPowerupPurchaseMonHook(SSGM_Purchase_Hook,0);
	}
	if (Settings->LogVehiclePurchase) {
		Data->VehiclePurchaseHookID = AddVehiclePurchaseMonHook(SSGM_Purchase_Hook,0);
	}

	if (!Data->Plugins.empty()) {
		std::vector<PluginInfo*>::const_iterator it;
		for (it = Data->Plugins.begin();it != Data->Plugins.end(); ++it) {
			if ((*it)->Type == Plugin) {
				if ((*it)->LevelLoadedHookHandle) {
					(*it)->LevelLoadedHookHandle();	
				}
			}
		}
	}
}


And in the SSGM plugin, there is a level_loaded event which looks like this (although you may wish to remove the settings loader part if you're not using it):

DLLEXPORT void SSGM_Level_Loaded_Hook() {
	ExampleSettings->Load();

}


Depending on whether you're putting this in a plugin, or SSGM directly, I would recomend using One of the above locations to put your function call in.


Your function may look like this:

void Wubs_Tick();

void Wubs_Tick()
{
	GameObject *ref = Find_Refinery(0);
	{
		Attach_Script_Once(ref, "JFW_Tiberium_Refinery", "5,1.00");
	}
	ref = Find_Refinery(1);
	if (ref)
	{
		Attach_Script_Once(ref, "JFW_Tiberium_Refinery", "5,1.00");
	}
}


So then after the level_loaded line in either SSGM or the plugin, you could simply call your function, like this:

DLLEXPORT void SSGM_Level_Loaded_Hook() {
	Wubs_Tick();
}



I made a simple extra tick rae plugin a little while ago, you can download the binary and source from my download page.
http://spencerelliott.co.uk/downloads.html



[Updated on: Thu, 16 September 2010 10:48]

Report message to a moderator

Re: Scripting help [message #436662 is a reply to message #436628] Thu, 16 September 2010 13:25 Go to previous messageGo to next message
wubwub is currently offline  wubwub
Messages: 142
Registered: May 2009
Location: Ontario
Karma: 0
Recruit
Thanks for the reply guys,

That info was helpful but Reborn that is written in c++ if i am not mistaken, i am trying to write it in lua but cant seem to get the script right.

(Sorry i didn't mention that beforehand Blush )

this is what i got so far, but i dont know how to translate c++ into lua

function OnLevelLoaded(target)
  Find_Refinery(Building_Type(0,3))
  Attach_Script_Building(Building_Type(3), "JFW_Tiberium_Refinery", "10,01.00")
end

end



This is what i am trying to base it off of in the engine.h:

int Building_Type(GameObject *obj); //returns the type of a BuildingGameObj
//type values for building objects
#define NONE -1
#define POWER_PLANT 0 //note that this list reflects the list in leveledit
#define SOLDIER_FACTORY 1
#define VEHICLE_FACTORY 2
#define REFINERY 3
#define COM_CENTER 4
#define REPAIR_BAY 5
#define SHRINE 6
#define HELIPAD 7
#define CONYARD 8
#define BASE_DEFENSE 9
GameObject *Find_Building(int team,int type); //Find a building by team and type


I am writing this as a plugin for lua

Everytime i load the server it gives error saying "bad argument #1 'Attach Script' <number expected, got string>"


p.s. i had previously attempted to use your tickrate plugin, but i didn't like that it gave creds ontop of the ref giving creds.

EDIT: could i just disable the refinery's and use your plugin to generate creds instead? or does te plugin still generate creds even after the ref is dead?


When renegade goes Wub, it never goes back

(or at least until I re-install renegade anyways)

http://i266.photobucket.com/albums/ii272/ZaydenX/Walrus-Sig.jpg

[Updated on: Thu, 16 September 2010 19:40]

Report message to a moderator

Re: Scripting help [message #436689 is a reply to message #436628] Fri, 17 September 2010 05:30 Go to previous message
reborn is currently offline  reborn
Messages: 3231
Registered: September 2004
Location: uk - london
Karma: 0
General (3 Stars)
The plugin carries on giving a tick rate even after the ref is dead, although it's easily changed to stop that behaviour.

You mentioned you didn't like it giving creds on top of the ref giving creds... Your LUA plugin using that jfw script is going to do exactly the same thing.

I would like to help with your LUA script, unfortunately it's not anything I'm familiar with.



Previous Topic: Tortoise SVN Public Repository
Next Topic: Cinematic Ion/Nuke Strike
Goto Forum:
  


Current Time: Fri Nov 01 04:46:24 MST 2024

Total time taken to generate the page: 0.01998 seconds