PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: Psycho_Chihuahua on 23 September, 2004, 16:04:43

Title: What have i done wrong here?
Post by: Psycho_Chihuahua on 23 September, 2004, 16:04:43
hmm this is an Anti Open Hub Standalone Script but i get this


Syntax error: attempt to index global `user' (a nil value)
stack traceback:
   1:  function `DataArrival' at line 2 [file `C:\hub\PtoKaX_new\scripts\antiopenhub.lua']


I'm using this

function DataArrival( sUser , sData )
if strsub( sData , 1 , 7 ) == "$MyINFO" and user.sName ~= "bobby" then
local _,_,openhubs = strfind( data , ".+H:(%d+)" );
if ( openhubs ~= "0" ) then
SendToNick( user.sName , "Du bist in einen oder mehreren Open Hubs. Dies verst?sst gegen unsere Regeln. Deshalb wird die Verbindung zur?ckgesetzt!")
user:Disconnect()
end
end
end
Title:
Post by: Herodes on 23 September, 2004, 16:18:48
Infact it is in three points ... or one :) any how u see it it is noted below ( both ways :)function DataArrival( sUser , sData )
if strsub( sData , 1 , 7 ) == "$MyINFO" and [b]sUser[/b].sName ~= "bobby" then
local _,_,openhubs = strfind( data , ".+H:(%d+)" );
if ( openhubs ~= "0" ) then
SendToNick( [b]sUser[/b].sName , "Du bist in einen oder mehreren Open Hubs. Dies verst?sst gegen unsere Regeln. Deshalb wird die Verbindung zur?ckgesetzt!")
[b]sUser[/b]:Disconnect()
end
end
end

and the second is .. function DataArrival( [b]user[/b] , sData )
if strsub( sData , 1 , 7 ) == "$MyINFO" and user.sName ~= "bobby" then
local _,_,openhubs = strfind( data , ".+H:(%d+)" );
if ( openhubs ~= "0" ) then
SendToNick( user.sName , "Du bist in einen oder mehreren Open Hubs. Dies verst?sst gegen unsere Regeln. Deshalb wird die Verbindung zur?ckgesetzt!")
user:Disconnect()
end
end
end

this is the first error to check if u are copy/paste'ing,...
 just keep it in mind :)
Title:
Post by: Psycho_Chihuahua on 23 September, 2004, 16:22:29
thnx herodes, i had it hooked up in Black_Pearl and couldn't find the original anymore lol.

hmm but it doesnt kick Users that r in Open Hubs :(
Title:
Post by: Herodes on 23 September, 2004, 16:42:06
check what u get from the strfind ...

local s,e,openhubs = strfind(data, ",H:(%d+)")
SendToAll("User :"..user.sName.." is in "..openhubs.." open hubs ")
Title:
Post by: Psycho_Chihuahua on 23 September, 2004, 17:20:53
hmm funny, cause in Black_Pearl it worked fine the way i had it....

but as Standalone i had to change _,_,openhubs to s,e,openhubs

but how come it works one way in a bot and stand alone not? This i dont understand
Title:
Post by: Herodes on 23 September, 2004, 17:30:27
from what I know using .. s,s,somevar = strfind(...) is the same with _,_,somevar = strfind(...) I always go with s,e any ways ...

but that should be a question for someone who really knows the languages inner-working :)
Title:
Post by: Psycho_Chihuahua on 23 September, 2004, 19:17:46
hmm well, maybe someone will tell me why its so *g*

guess i'll just have to wait