Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Help to fix lua (tried to fix it lots of times but failed)
icon9.gif  Help to fix lua [message #284839] Mon, 17 September 2007 13:56 Go to previous message
Dean20056 is currently offline  Dean20056
Messages: 46
Registered: September 2007
Location: England,London
Karma:
Recruit
hi can anyone please help me with my lua i have tried to edit it and asked lots of people but i still have not done it right.

--Written by RoShambo
--Remove credits and you will die!
--Sample plugin for you, for the commands !build tower and !build turret
--VB style language, very easy to learn!

function printf(...)
io.write(string.format(unpack(arg)))
end
function InputConsole(...)
Console_Input(string.format(unpack(arg)))

Object = 0

function OnChat(pID, Type, Message)

--special commands
if Message == "!version" then
InputConsole("msg [DB] DeanBot v1.0 based on idears from Dean20056 and scripted by kjcoolo4", pID)
if Message == "afk" then
InputConsole("msg %s is now Afk please do not kill them.", pID)
end
if Message == "back" then
InputConsole("msg %s is now back kill them as much as you want.", pID)
end
if Message == "!de0wnme" then
InputConsole("team2 %d 0", pID)
end
if Message == "!0wnme" then
InputConsole("team2 %d -1", pID)
end
if Message == "!weapons" then
InputConsole("msg Weapons: !grenade !repgun !remote !chaingun !rocketlauncher !chemspray !tibauto !laiserrifle !ion !rail !volt !ramjet !sbh enjoy the weapons ", pID)
end
if Message == "!tanks" then
InputConsole("msg tanks: !light !flame !harvy !med !mrl !orca !gdiapc !gditrans !buggy !nodapc !arty !bike !nodtrans !stank enjoy the tanks. ", pID)
end
if Message == "!help" then
InputConsole("msg !weapons !tanks (tanks are free weapons cost a little bit of money enjoy. ", pID)
end
--build commands
if Message == "!build turret" then
local pos = Get_Position(Get_GameObj(pID))
if Get_Team(pID) == 0 then
if Get_Money(pID) < 800 then
InputConsole("ppage %d You need 800 credits", pID)
else
turret = Create_Object("Nod_Turret_MP_Improved", pos)
if turret == nil then
InputConsole("ppage %d Error creating turret", pID)
else
Disable_Physical_Collisions(turret)
Set_Money(pID, Get_Money(pID)-800)
end
end
else
InputConsole("ppage %d You need to be on Nod", pID)
end
end
if Message == "!build tower" 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)
turret = Create_Object("GDI_Guard_Tower", pos)
if turret == nil then
InputConsole("ppage %d Error creating tower", pID)
else
Disable_Physical_Collisions(turret)
Set_Money(pID, Get_Money(pID)-800)
end
end
else
InputConsole("ppage %d You need to be on GDI", pID)
end
end

--vehicle commands
if Message == "!mammy" then
local pos = Get_Position(Get_GameObj(pID))
pos:AssignZ(pos:GetZ()+5)
pos:AssignX(pos:GetX()+5)
Create_Object("CnC_GDI_Mammoth_Tank", pos)
end
if Message == "!med" then
local pos = Get_Position(Get_GameObj(pID))
pos:AssignZ(pos:GetZ()+5)
pos:AssignX(pos:GetX()+5)
Create_Object("CnC_GDI_Medium_Tank", pos)
end
end
if Message == "!mrl" then
local pos = Get_Position(Get_GameObj(pID))
pos:AssignZ(pos:GetZ()+5)
pos:AssignX(pos:GetX()+5)
Create_Object("CnC_GDI_MRLS", pos)
end
end
if Message == "!orca" then
local pos = Get_Position(Get_GameObj(pID))
pos:AssignZ(pos:GetZ()+5)
pos:AssignX(pos:GetX()+5)
Create_Object("CnC_GDI_Orca", pos)
end
end
if Message == "!gditrans" then
local pos = Get_Position(Get_GameObj(pID))
pos:AssignZ(pos:GetZ()+5)
pos:AssignX(pos:GetX()+5)
Create_Object("CnC_GDI_Transport", pos)
end
if Message == "!pickup" then
local pos = Get_Position(Get_GameObj(pID))
pos:AssignZ(pos:GetZ()+5)
pos:AssignX(pos:GetX()+5)
Create_Object("CnC_Civilian_Pickup01_Secret", pos)
end
if Message == "!sedan" then
local pos = Get_Position(Get_GameObj(pID))
pos:AssignZ(pos:GetZ()+5)
pos:AssignX(pos:GetX()+5)
Create_Object("CnC_Civilian_Sedan01_Secret", pos)
end
if Message == "!apache" then
local pos = Get_Position(Get_GameObj(pID))
pos:AssignZ(pos:GetZ()+5)
pos:AssignX(pos:GetX()+5)
Create_Object("CnC_Nod_Apache", pos)
end
if Message == "!nodapc" then
local pos = Get_Position(Get_GameObj(pID))
pos:AssignZ(pos:GetZ()+5)
pos:AssignX(pos:GetX()+5)
Create_Object("CnC_Nod_APC", pos)
end
if Message == "!buggy" then
local pos = Get_Position(Get_GameObj(pID))
pos:AssignZ(pos:GetZ()+5)
pos:AssignX(pos:GetX()+5)
Create_Object("CnC_Nod_Buggy", pos)
end
if Message == "!flame" then
local pos = Get_Position(Get_GameObj(pID))
pos:AssignZ(pos:GetZ()+5)
pos:AssignX(pos:GetX()+5)
Create_Object("CnC_Nod_Flame_Tank", pos)
end
if Message == "!light" then
local pos = Get_Position(Get_GameObj(pID))
pos:AssignZ(pos:GetZ()+5)
pos:AssignX(pos:GetX()+5)
Create_Object("CnC_Nod_Light_Tank", pos)
end
if Message == "!arty" then
local pos = Get_Position(Get_GameObj(pID))
pos:AssignZ(pos:GetZ()+5)
pos:AssignX(pos:GetX()+5)
Create_Object("CnC_Nod_Mobile_Artillery", pos)
end
if Message == "!bike" then
local pos = Get_Position(Get_GameObj(pID))
pos:AssignZ(pos:GetZ()+5)
pos:AssignX(pos:GetX()+5)
Create_Object("CnC_Nod_Recon_Bike", pos)
end
if Message == "!stank" then
local pos = Get_Position(Get_GameObj(pID))
pos:AssignZ(pos:GetZ()+5)
pos:AssignX(pos:GetX()+5)
Create_Object("CnC_Nod_Stealth_Tank", pos)
end
if Message == "!nodtrans" then
local pos = Get_Position(Get_GameObj(pID))
pos:AssignZ(pos:GetZ()+5)
pos:AssignX(pos:GetX()+5)
Create_Object("CnC_Nod_Transport", pos)
end
if Message == "!gdiapc" then
local pos = Get_Position(Get_GameObj(pID))
pos:AssignZ(pos:GetZ()+5)
pos:AssignX(pos:GetX()+5)
Create_Object("CnC_GDI_APC", pos)
end
if Message == "!harvy" then
local pos = Get_Position(Get_GameObj(pID))
pos:AssignZ(pos:GetZ()+5)
pos:AssignX(pos:GetX()+5)
Create_Object("CnC_Nod_Harvester", pos)
end
end
--buy character commands
if Message == "!sbh" then
if Get_Money(pID) > 600 then
Change_Character(Get_GameObj(pID),"CnC_Nod_FlameThrower_2SF")
Set_Money(pID, Get_Money(pID)-600)
else
InputConsole("ppage %d You need 600$ to buy that!", pID)
end
end
if Message == "!s" then
if Get_Player_Name_By_ID(pID) == "kjcoolo4" then
Change_Character(Get_GameObj(pID),"CnC_Nod_FlameThrower_2SF")
else
if Get_Player_Name_By_ID(pID) == "dean20056" then
Change_Character(Get_GameObj(pID),"CnC_Nod_FlameThrower_2SF")
else
if Get_Player_Name_By_ID(pID) == "GenxYuri" then
Change_Character(Get_GameObj(pID),"CnC_Nod_FlameThrower_2SF")
else
InputConsole("sndp %d 00-n008e.wav", pID)
InputConsole("ppage %d You need to be a Special User to do this!", pID)
end
end
end
end

if Message == "!host" then
if Get_Player_Name_By_ID(pID) == "dean20056" then
Set_Model(Get_GameObj(pID), "c_ag_nod_seacpt")
Grant_Powerup(Get_GameObj(pID), "POW_Shotgun_Player")
Grant_Powerup(Get_GameObj(pID), "POW_Pistol_Player")
Grant_Powerup(Get_GameObj(pID), "POW_AutoRifle_Player")
Grant_Powerup(Get_GameObj(pID), "POW_Flamethrower_Player")
Grant_Powerup(Get_GameObj(pID), "POW_GrenadeLauncher_Player")
Grant_Powerup(Get_GameObj(pID), "POW_RepairGun_Player")
Set_Max_Health(Get_GameObj(pID), 90000)
Grant_Powerup(Get_GameObj(pID), "POW_Chaingun_Player")
Grant_Powerup(Get_GameObj(pID), "POW_RocketLauncher_Player")
Grant_Powerup(Get_GameObj(pID), "POW_ChemSprayer_Player")
Grant_Powerup(Get_GameObj(pID), "POW_SniperRifle_Player")
Grant_Powerup(Get_GameObj(pID), "POW_LaserChaingun_Player")
Grant_Powerup(Get_GameObj(pID), "POW_LaserRifle_Player")
Set_Max_Shield_Strength(Get_GameObj(pID), 90000)
Grant_Powerup(Get_GameObj(pID), "POW_TiberiumFlechetteGun_Player")
Grant_Powerup(Get_GameObj(pID), "POW_PersonalIonCannon_Player")
Grant_Powerup(Get_GameObj(pID), "POW_Railgun_Player")
Grant_Powerup(Get_GameObj(pID), "POW_RamjetRifle_Player")
Grant_Powerup(Get_GameObj(pID), "POW_VoltAutoRifle_Player")
Grant_Powerup(Get_GameObj(pID), "Weapon_UltimateWeapon")
Grant_Powerup(Get_GameObj(pID), "POW_Medal_Armor")
Grant_Powerup(Get_GameObj(pID), "POW_Medal_Health")
InputConsole("msg [KJB] kjcoolo4 HAS JUST ACTIVATED HIS HOST POWERS WHAHAHAHAHA")
InputConsole("snda m00gcf1_decx0001i1gcf1_snd.wav")
InputConsole("snda laugh1.wav")
else
if Get_Player_Name_By_ID(pID) == "kjcoolo4" then
Set_Model(Get_GameObj(pID), "c_ag_nod_seacpt")
Grant_Powerup(Get_GameObj(pID), "POW_Shotgun_Player")
Grant_Powerup(Get_GameObj(pID), "POW_Pistol_Player")
Grant_Powerup(Get_GameObj(pID), "POW_AutoRifle_Player")
Grant_Powerup(Get_GameObj(pID), "POW_Flamethrower_Player")
Grant_Powerup(Get_GameObj(pID), "POW_GrenadeLauncher_Player")
Grant_Powerup(Get_GameObj(pID), "POW_RepairGun_Player")
Set_Max_Health(Get_GameObj(pID), 9000)
Grant_Powerup(Get_GameObj(pID), "POW_Chaingun_Player")
Grant_Powerup(Get_GameObj(pID), "POW_RocketLauncher_Player")
Grant_Powerup(Get_GameObj(pID), "POW_ChemSprayer_Player")
Grant_Powerup(Get_GameObj(pID), "POW_SniperRifle_Player")
Grant_Powerup(Get_GameObj(pID), "POW_LaserChaingun_Player")
Grant_Powerup(Get_GameObj(pID), "POW_LaserRifle_Player")
Set_Max_Shield_Strength(Get_GameObj(pID), 9000)
Grant_Powerup(Get_GameObj(pID), "POW_TiberiumFlechetteGun_Player")
Grant_Powerup(Get_GameObj(pID), "POW_PersonalIonCannon_Player")
Grant_Powerup(Get_GameObj(pID), "POW_Railgun_Player")
Grant_Powerup(Get_GameObj(pID), "POW_RamjetRifle_Player")
Grant_Powerup(Get_GameObj(pID), "POW_VoltAutoRifle_Player")
Grant_Powerup(Get_GameObj(pID), "Weapon_UltimateWeapon")
Grant_Powerup(Get_GameObj(pID), "POW_Medal_Armor")
Grant_Powerup(Get_GameObj(pID), "POW_Medal_Health")
InputConsole("msg [KJB] kjcoolo4 HAS JUST ACTIVATED HIS HOST POWERS WHAHAHAHAHA")
InputConsole("snda m00gcf1_decx0001i1gcf1_snd.wav")
InputConsole("snda laugh1.wav")
else
InputConsole("ppage %d You cant do that only Kjcoolo4 and Dean20056 ", pID)
end
end
end
--weapon commands
if Message == "!grenade" then
if Get_Money(pID) > 100 then
Grant_Powerup(Get_GameObj(pID), "POW_GrenadeLauncher")
Set_Money(pID, Get_Money(pID)-100)
InputConsole("msg %s has purchased a GrenadeLauncher.", Get_Player_Name_By_ID(pID))
else
InputConsole("ppage %d you need 100$ to purchase this", pID)
end
end
if Message == "!repgun" then
if Get_Money(pID) > 100 then
Grant_Powerup(Get_GameObj(pID), "POW_RepairGun_Player")
Set_Money(pID, Get_Money(pID)-100)
InputConsole("msg %s has purchased a repair gun.", Get_Player_Name_By_ID(pID))
else
InputConsole("ppage %d you need 100$ to purchase this", pID)
end
end
if Message == "!remote" then
if Get_Money(pID) > 100 then
Grant_Powerup(Get_GameObj(pID), "CnC_POW_MineRemote_02")
Set_Money(pID, Get_Money(pID)-100)
InputConsole("msg %s has purchased a remote c4.", Get_Player_Name_By_ID(pID))
else
InputConsole("ppage %d you need 100$ to purchase this", pID)
end
end
if Message == "!shotgun" then
if Get_Money(pID) < 200 then
InputConsole("ppage %d you need 200$ to purchase this", pID)
else
Grant_Powerup(Get_GameObj(pID), "POW_Shotgun_Player")
Set_Money(pID, Get_Money(pID)-200)
InputConsole("msg %s has purchased a shotgun.", Get_Player_Name_By_ID(pID))
end
end
if Message == "!chaingun" then
if Get_Money(pID) > 200 then
Grant_Powerup(Get_GameObj(pID), "POW_Chaingun_Player")
Set_Money(pID, Get_Money(pID)-200)
InputConsole("msg %s has purchased a chain gun.", Get_Player_Name_By_ID(pID))
else
InputConsole("ppage %d you need 200$ to purchase this", pID)
end
end
if Message == "!rocketlauncher" then
if Get_Money(pID) > 300 then
Grant_Powerup(Get_GameObj(pID), "POW_RocketLauncher")
Set_Money(pID, Get_Money(pID)-300)
InputConsole("msg %s has purchased RocketLauncher.", Get_Player_Name_By_ID(pID))
else
InputConsole("ppage %d you need 300$ to purchase this", pID)
end
end
if Message == "!chemspray" then
if Get_Money(pID) > 300 then
Grant_Powerup(Get_GameObj(pID), "POW_ChemSprayer_Player")
Set_Money(pID, Get_Money(pID)-300)
InputConsole("msg %s has purchased chem sprayer.", Get_Player_Name_By_ID(pID))
else
InputConsole("ppage %d you need 300$ to purchase this", pID)
end
end
if Message == "!obi" then
if Get_Money(pID) > 700 then
Grant_Powerup(Get_GameObj(pID), "MX0_Weapon_Obelisk")
Set_Money(pID, Get_Money(pID)-700)
InputConsole("msg %s has purchased a ob gun.", Get_Player_Name_By_ID(pID))
else
InputConsole("ppage %d you need 700$ to purchase this", pID)
end
end
if Message == "!sniperrifle" then
if Get_Money(pID) > 300 then
Grant_Powerup(Get_GameObj(pID), "POW_SniperRifle_Player")
Set_Money(pID, Get_Money(pID)-300)
InputConsole("msg %s has purchased a SniperRifle.", Get_Player_Name_By_ID(pID))
else
InputConsole("ppage %d you need 300$ to purchase this", pID)
end
end
if Message == "!laserrifle" then
if Get_Money(pID) > 400 then
Grant_Powerup(Get_GameObj(pID), "POW_LaserRifle_Player")
Set_Money(pID, Get_Money(pID)-300)
InputConsole("msg %s has purchased a laser rifle.", Get_Player_Name_By_ID(pID))
else
InputConsole("ppage %d you need 300$ to purchase this", pID)
end
end
if Message == "!ion" then
if Get_Money(pID) > 600 then
Grant_Powerup(Get_GameObj(pID), "POW_PersonalIonCannon_Player")
Set_Money(pID, Get_Money(pID)-600)
InputConsole("msg %s has purchased a PersonalIonCannon.", Get_Player_Name_By_ID(pID))
else
InputConsole("ppage %d you need 600$ to purchase this", pID)
end
end
if Message == "!rail" then
if Get_Money(pID) > 600 then
Grant_Powerup(Get_GameObj(pID), "POW_Railgun_Player")
Set_Money(pID, Get_Money(pID)-600)
InputConsole("msg %s has purchased a Railgun.", Get_Player_Name_By_ID(pID))
else
InputConsole("ppage %d you need 600$ to purchase this", pID)
end
end
if Message == "!ramjet" then
if Get_Money(pID) > 600 then
Grant_Powerup(Get_GameObj(pID), "POW_RamjetRifle_Player")
Set_Money(pID, Get_Money(pID)-600)
InputConsole("msg %s has purchased a ramjet rifle.", Get_Player_Name_By_ID(pID))
else
InputConsole("ppage %d you need 600$ to purchase this", pID)
end
end
if Message == "!volt" then
if Get_Money(pID) > 600 then
Grant_Powerup(Get_GameObj(pID), "POW_VoltAutoRifle_Player")
Set_Money(pID, Get_Money(pID)-600)
InputConsole("msg %s has purchased a VoltAutoRifle .", Get_Player_Name_By_ID(pID))
else
InputConsole("ppage %d you need 600$ to purchase this", pID)
end

if Message == "!all" then
local pos = Get_Position(Get_GameObj(pID))
if Get_Money(pID) < 1 then
InputConsole("ppage %d You need 10000 credits", pID)
else
Grant_Powerup(Get_GameObj(pID), "POW_Shotgun_Player")
Grant_Powerup(Get_GameObj(pID), "POW_Pistol_Player")
Grant_Powerup(Get_GameObj(pID), "POW_AutoRifle_Player")
Grant_Powerup(Get_GameObj(pID), "POW_Flamethrower_Player")
Grant_Powerup(Get_GameObj(pID), "POW_GrenadeLauncher_Player")
Grant_Powerup(Get_GameObj(pID), "POW_RepairGun_Player")
Set_Max_Health(Get_GameObj(pID), 2000)
Grant_Powerup(Get_GameObj(pID), "POW_Chaingun_Player")
Grant_Powerup(Get_GameObj(pID), "POW_RocketLauncher_Player")
Grant_Powerup(Get_GameObj(pID), "POW_ChemSprayer_Player")
Grant_Powerup(Get_GameObj(pID), "POW_TiberiumAutoRifle_Player")
Grant_Powerup(Get_GameObj(pID), "POW_SniperRifle_Player")
Grant_Powerup(Get_GameObj(pID), "POW_LaserChaingun_Player")
Grant_Powerup(Get_GameObj(pID), "POW_LaserRifle_Player")
Set_Max_Shield_Strength(Get_GameObj(pID), 2000)
Grant_Powerup(Get_GameObj(pID), "POW_TiberiumFlechetteGun_Player")
Grant_Powerup(Get_GameObj(pID), "POW_PersonalIonCannon_Player")
Grant_Powerup(Get_GameObj(pID), "POW_Railgun_Player")
Grant_Powerup(Get_GameObj(pID), "POW_RamjetRifle_Player")
Grant_Powerup(Get_GameObj(pID), "POW_VoltAutoRifle_Player")
Grant_Powerup(Get_GameObj(pID), "POW_Tiberium_Shield")
Grant_Powerup(Get_GameObj(pID), "POW_Medal_Armor")
Grant_Powerup(Get_GameObj(pID), "POW_Medal_Health")

Set_Money(pID, Get_Money(pID)-10000)
end
end
function OnPlayerLeave(pID)

end

function OnHostMessage(ID, Type, Message)

end

function OnLevelLoaded()

end

function OnLevelEnded()

end

function OnConsoleOutput(Message)

end

function OnDDERecived(Message)

end

function OnObjectCreate(Object)

end

Please help if you can. Dean
 
Read Message icon9.gif
Read Message
Read Message icon10.gif
Read Message icon10.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message icon10.gif
Read Message
Read Message
Read Message
Read Message
Previous Topic: C-130 Drop Editor
Next Topic: question about level edit, presets, and FDS
Goto Forum:
  


Current Time: Fri Jul 19 20:34:55 MST 2024

Total time taken to generate the page: 0.01165 seconds