Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Having problems with Attach_Script_Once
Having problems with Attach_Script_Once [message #468584] Fri, 08 June 2012 01:43 Go to next message
Distrbd21 is currently offline  Distrbd21
Messages: 743
Registered: September 2008
Karma: 0
Colonel

It say's that the first Get_Parameter is undefined.
I'm trying to set up Samsites for players to be able to buy them, and so they will attack only helis.

				char params[256];
				sprintf(params, "%d,%s,%s,%s,%s,%s,%s,%s",params,Get_Parameter("0.0"),Get_Parameter("300.0"),Get_Parameter("10.0"),Get_Parameter("CnC_GDI_Orca"),Get_Parameter("CnC_GDI_Transport"),Get_Parameter("CnC_Nod_Apache"),Get_Parameter("CnC_Nod_Transport"));
				Attach_Script_Once(nsam,"JFW_Base_Defence_Aircraft_Only",params);


here is the Sam site buy codes.
		if (wcsistr(Message,L"!gsam") == Message)
		{
			GameObject *Player = Get_GameObj(PlayerID);
			{
            float money = Commands->Get_Money(Player);
            float cost = 1000;
            if (money >= cost)
			{
			int team = Commands->Get_Player_Type(Player);
            if (team == 1)
            {
                Commands->Give_Money(Player,-1000,false);
                Vector3 pos = Commands->Get_Position(Player);
                pos.Z+=2.0f;
                GameObject *gsam = Commands->Create_Object("Nod_SAM_Site",pos);
				Commands->Set_Player_Type(gsam,0);
                Commands->Disable_Physical_Collisions(gsam);
				char params[256];
				sprintf(params, "%d,%s,%s,%s,%s,%s,%s,%s",params,Get_Parameter("0.0"),Get_Parameter("300.0"),Get_Parameter("10.0"),Get_Parameter("CnC_GDI_Orca"),Get_Parameter("CnC_GDI_Transport"),Get_Parameter("CnC_Nod_Apache"),Get_Parameter("CnC_Nod_Transport"));
				Attach_Script_Once(gsam,"JFW_Base_Defence_Aircraft_Only",params);
                char msg[250];
                sprintf(msg,"[DefBot] %s purchased a Samsite for 1000 credits.",Get_Player_Name(Player),1000);
                Send_Message_Team(1,255,255,0,msg);
                Create_2D_WAV_Sound_Team("m00evan_dsgn0002i1evan_snd.wav",1);
        }
        else
        {
                char infunds[250];
                sprintf(infunds,"[DefBot] Insufficient Funds: Samsite cost 1000 credits on this map",1000);
                Send_Message_Team(1,255,255,0,infunds);
                Create_2D_WAV_Sound_Team("m00evan_dsgn0024i1evan_snd.wav",1);
		}
			team = 1;
			}
		}
		}
		if (wcsistr(Message,L"!nsam") == Message)
		{
			GameObject *Player = Get_GameObj(PlayerID);
			{
            float money = Commands->Get_Money(Player);
            float cost = 1000;
            if (money >= cost)
			{
			int team = Commands->Get_Player_Type(Player);
            if (team == 0)
            {
                Commands->Give_Money(Player,-1000,false);
                Vector3 pos = Commands->Get_Position(Player);
                pos.Z+=2.0f;
                GameObject *nsam = Commands->Create_Object("Nod_SAM_Site",pos);
				Commands->Set_Player_Type(nsam,0);
                Commands->Disable_Physical_Collisions(nsam);
				char params[256];
				sprintf(params, "%d,%s,%s,%s,%s,%s,%s,%s",params,Get_Parameter("0.0"),Get_Parameter("300.0"),Get_Parameter("10.0"),Get_Parameter("CnC_GDI_Orca"),Get_Parameter("CnC_GDI_Transport"),Get_Parameter("CnC_Nod_Apache"),Get_Parameter("CnC_Nod_Transport"));
				Attach_Script_Once(nsam,"JFW_Base_Defence_Aircraft_Only",params);
                char msg[250];
                sprintf(msg,"[DefBot] %s purchased a Samsite for 1000 credits.",Get_Player_Name(Player),1000);
                Send_Message_Team(0,255,0,0,msg);
                Create_2D_WAV_Sound_Team("m00evan_dsgn0002i1evan_snd.wav",0);
        }
        else
        {
                char infunds[250];
                sprintf(infunds,"[DefBot] Insufficient Funds: Samsite cost 1000 credits on this map",1000);
                Send_Message_Team(0,255,0,0,infunds);
                Create_2D_WAV_Sound_Team("m00evan_dsgn0024i1evan_snd.wav",0);
			}
			team = 0;
			}
		}
		}


Live Your Life Not Some one Else's.| Sharing Is Caring

http://dsgaming.us/distrbd21/Distrbd21%20siggy.png

Cookie Jar

Suicide

[Updated on: Fri, 08 June 2012 01:47]

Report message to a moderator

Re: Having problems with Attach_Script_Once [message #468607 is a reply to message #468584] Fri, 08 June 2012 05:44 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3809
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
For starters:
char params[256];
sprintf(params, "%d,%s,%s,%s,%s,%s,%s,%s",params,Get_Parameter("0.0"),Get_Parameter("300.0"),Get_Parameter("10.0"),Get_Parameter("CnC_GDI_Orca"),Get_Parameter("CnC_GDI_Transport"),Get_Parameter("CnC_Nod_Apache"),Get_Parameter("CnC_Nod_Transport"));
Attach_Script_Once(nsam,"JFW_Base_Defence_Aircraft_Only",params);


Should pobably be like this:

char params[256];
sprint(params,"0.0,300.0,10.0,CnC_GDI_Orca, CnC_GDI_Transport,CnC_Nod_Apache,CnC_Nod_Transport");
Attach_Script_Once(nsam,"JFW_Base_Defence_Aircraft_Only",params);



Or even better
Attach_Script_Once(nsam,"JFW_Base_Defence_Aircraft_Only","0.0,300.0,10.0,CnC_GDI_Orca, CnC_GDI_Transport,CnC_Nod_Apache,CnC_Nod_Transport");



Also, feeding params back into params is a bad idea:
sprintf(params,"%d",params);

plus it won't work like that, because params is a char and %d is for int.

The only time feeding a string back into itself is useful is if you have the origial string set to something, otherwise you risk filling it with junk.

IE:
char params[256];
sprintf(params,"stuff");
sprintf(params,"%s is stuff",params);
Console_Input(params);

would give you:
stuff is stuff


[Updated on: Fri, 08 June 2012 05:52]

Report message to a moderator

Re: Having problems with Attach_Script_Once [message #468608 is a reply to message #468584] Fri, 08 June 2012 06:22 Go to previous messageGo to next message
Distrbd21 is currently offline  Distrbd21
Messages: 743
Registered: September 2008
Karma: 0
Colonel

Thanks but I got help like half hour ago, we went with the simple one.

Live Your Life Not Some one Else's.| Sharing Is Caring

http://dsgaming.us/distrbd21/Distrbd21%20siggy.png

Cookie Jar

Suicide
Re: Having problems with Attach_Script_Once [message #468615 is a reply to message #468584] Fri, 08 June 2012 07:04 Go to previous message
Distrbd21 is currently offline  Distrbd21
Messages: 743
Registered: September 2008
Karma: 0
Colonel

Here's the fixed version just in case someone else wants to use it.
Big Grin
		if (wcsistr(Message,L"!sam") == Message)
		{
			GameObject *Player = Get_GameObj(PlayerID);
			{
				if(!Is_Map_Flying()) {
					Send_Message_Player(Player,255,255,127,"[DefBot] You need to be on a flying map to use !sam");
					return false;
				}
				float money = Commands->Get_Money(Player);
				float cost = 1000;
				if (money >= cost)
				{
					int team = Commands->Get_Player_Type(Player);
					if (Commands->Get_Money(Player)<1000)
					{
						Commands->Give_Money(Player,-1000,false);
						Vector3 pos = Commands->Get_Position(Player);
						pos.Z+=0.1f;
						GameObject *sam = Commands->Create_Object("Nod_SAM_Site",pos);
						Commands->Set_Player_Type(sam, team);
						Commands->Disable_Physical_Collisions(sam);
						Attach_Script_Once(sam,"JFW_Base_Defence_Aircraft_Only", "0.0,300.0,10.0,CnC_GDI_Orca,CnC_GDI_Transport,CnC_Nod_Apache,CnC_Nod_Transport");
						Send_Message_Player(Player,0,255,0,"[DefBot] %s You just bought a Samsite for your team.");
						Create_2D_WAV_Sound_Player(Player,"m00evan_dsgn0002i1evan_snd.wav");
					}
					else
					{
						Send_Message_Player(Player,0,255,0,"[DefBot] Insufficient Funds: Samsite cost 1000 credits.");
						Create_2D_Sound_Player(Player,"m00evan_dsgn0024i1evan_snd.wav");
					}
				}
			}
		}
		return false;
	}


Only one code and it works with both GDI and Nod. ;p


Live Your Life Not Some one Else's.| Sharing Is Caring

http://dsgaming.us/distrbd21/Distrbd21%20siggy.png

Cookie Jar

Suicide
Previous Topic: I don't get why it don't page the player...
Next Topic: Where can I find Jonwil's Level editor?
Goto Forum:
  


Current Time: Sat Nov 02 07:03:13 MST 2024

Total time taken to generate the page: 0.00626 seconds