General > Developers Corner
PointShop Respawn (for TTT)
Zmaster:
I tried to do this on my own, and I did as much as I could, but I'm still very new to Lua and don't really know much
I am trying to create a "product" in the PointShop that will respawn a player. I took some of the code from a TTT respawn command I got in a pack of other TTT commands
Here's what I have right now
--- Code: ---ITEM.Name = 'Respawn'
ITEM.Price = 20000
ITEM.Model = 'models/xqm/jetengine.mdl'
ITEM.SingleUse = true
ITEM.Except = true
function ITEM:OnEquip(ply, modifications)
if not GetConVarString("gamemode") == "terrortown" then print("Wrong gamemode. Please switch to TTT for this to work.")
end
if v:Alive() then return end
local corpse = corpse_find(v)
if corpse then corpse_remove(corpse) end
v:SpawnForRound( true )
v:SetCredits( ( (v:GetRole() == ROLE_INNOCENT) and 0 ) or GetConVarNumber("ttt_credits_starting") )
end
end
--- End code ---
And here's the error I'm getting
Avoid:
Hello there,
please read the error message, it cleary states what is wrong!
You do have an extra, not needed end in your function..
Avoid
Neku:
Well, first of all, you're saying the player is v.
According to your code, you have not set v to be anything.
Zmaster:
--- Quote from: Avoid on July 21, 2014, 03:45:48 PM ---Hello there,
please read the error message, it cleary states what is wrong!
You do have an extra, not needed end in your function..
Avoid
--- End quote ---
I did, and I saw respawn.lua:20: '<eof>'
I had no idea what eof meant, so I decided to post here
--- Quote from: Neku on July 21, 2014, 04:15:09 PM ---Well, first of all, you're saying the player is v.
According to your code, you have not set v to be anything.
--- End quote ---
Alright, I changed every "v" to "ply", since I noticed that ply is used in other pointshop item files, and now when I buy Respawn from the PointShop, it does absolutely nothing. There's no errors or anything at all.
However, I'd like to use v instead of ply, so I guess I still have to define that
Again, I'm still pretty new to Lua, so how would I do that
An Error Has Occurred!
array_keys(): Argument #1 ($array) must be of type array, null given
[0] Board index
Go to full version