ULX

Author Topic: PointShop Respawn (for TTT)  (Read 4062 times)

0 Members and 1 Guest are viewing this topic.

Offline Zmaster

  • Full Member
  • ***
  • Posts: 235
  • Karma: 25
PointShop Respawn (for TTT)
« on: July 21, 2014, 03:29:02 PM »
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: [Select]
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

And here's the error I'm getting

Offline Avoid

  • Full Member
  • ***
  • Posts: 142
  • Karma: 42
Re: PointShop Respawn (for TTT)
« Reply #1 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

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: PointShop Respawn (for TTT)
« Reply #2 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.
Out of the Garry's Mod business.

Offline Zmaster

  • Full Member
  • ***
  • Posts: 235
  • Karma: 25
Re: PointShop Respawn (for TTT)
« Reply #3 on: July 21, 2014, 08:23:47 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

I did, and I saw respawn.lua:20: '<eof>'
I had no idea what eof meant, so I decided to post here

Well, first of all, you're saying the player is v.
According to your code, you have not set v to be anything.
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