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   | 
		 
		
			
				
				
				  | 
					
						  
						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  
 
Cookie Jar<glome> Who stole the cookie from the cookie jar?! 
<content> glome stole the cookie from the cookie jar! 
<glome> Who me?! 
<content> Yes you! 
<glome> Couldn't be! 
<content> Then WHO?!! 
<glome> Woody stole the cookie from the cookie jar! 
*** glome has been kicked by DrWoody (fuck you i didn't touch the motherfucking cookie, bitch   
Suicide<TB>  I was depressed last night so I called the Suicide Life Line. 
<TB>  I reached a call center in Pakistan. 
<TB>  I told them I was suicidal. 
<TB>  They got all excited and asked if I could drive a truck  
		[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    | 
		 
		
			
				
				
				  | 
					
						  
						Jerad2142
						 Messages: 3826 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: 
		
		
 
  
Visit Jerad's deer sweat shop
		[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    | 
		 
		
			
				
				
				  | 
					
						  
						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  
 
Cookie Jar<glome> Who stole the cookie from the cookie jar?! 
<content> glome stole the cookie from the cookie jar! 
<glome> Who me?! 
<content> Yes you! 
<glome> Couldn't be! 
<content> Then WHO?!! 
<glome> Woody stole the cookie from the cookie jar! 
*** glome has been kicked by DrWoody (fuck you i didn't touch the motherfucking cookie, bitch   
Suicide<TB>  I was depressed last night so I called the Suicide Life Line. 
<TB>  I reached a call center in Pakistan. 
<TB>  I told them I was suicidal. 
<TB>  They got all excited and asked if I could drive a truck  
		
 |  
	| 
		
	 | 
 
 
 |  
	
		
		
			| Re: Having problems with Attach_Script_Once [message #468615 is a reply to message #468584] | 
			Fri, 08 June 2012 07:04   | 
		 
		
			
				
				
				  | 
					
						  
						Distrbd21
						 Messages: 743 Registered: September 2008 
						
	Karma: 0
 
					 | 
					Colonel  | 
					 
  | 
		 
		 
	 | 
 
	
		Here's the fixed version just in case someone else wants to use it. 
    
		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  
 
Cookie Jar<glome> Who stole the cookie from the cookie jar?! 
<content> glome stole the cookie from the cookie jar! 
<glome> Who me?! 
<content> Yes you! 
<glome> Couldn't be! 
<content> Then WHO?!! 
<glome> Woody stole the cookie from the cookie jar! 
*** glome has been kicked by DrWoody (fuck you i didn't touch the motherfucking cookie, bitch   
Suicide<TB>  I was depressed last night so I called the Suicide Life Line. 
<TB>  I reached a call center in Pakistan. 
<TB>  I told them I was suicidal. 
<TB>  They got all excited and asked if I could drive a truck  
		
 |  
	| 
		
	 | 
 
 
 |   
Goto Forum:
 
 Current Time: Mon Nov 03 21:50:53 MST 2025 
 Total time taken to generate the page: 0.00657 seconds 
 |