Forum

> > CS2D > Scripts > Will this work?
Forums overviewCS2D overview Scripts overviewLog in to reply

English Will this work?

7 replies
To the start Previous 1 Next To the start

old Will this work?

Louie
User Off Offline

Quote
So i'm trying to make a Admin script to use on my server,and when someone plays for a certain amount of time then i make that player have a VIP rank,just wondering will this work?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
addhook("say","setrank")
function setrank(id,txt)
   for _, usgn in ipairs(OWNER) do
      if player(id,'usgn') == usgn then 
        if txt:sub(1,8) == "!makevip" then
           vipid = txt:sub(10,#txt)
           table.add(VIP,"..player(vipid,'usgn')..")
           msg2(id,"You have made "..player(vipid,'name').." a VIP,his/hers USGN:"..player(vipid,'usgn'))
           msg2(vipid,"You are now a VIP!")
        elseif txt:sub(1,9) == "removevip" then
           rvipid = txt:sub(11,#txt)
           table.remove(VIP,"..player(rvipid,'usgn')..")
           msg2(id,"You have removed "..player(vipid,'name').." as a VIP")
           msg2(rvipid,"You are no longer a VIP!")
        end
      end
   end
end
that's part of my script.

old Re: Will this work?

Rainoth
Moderator Off Offline

Quote
Why don't you run it and see for yourself?
I didn't pay much attention but the only thing I'd change is "vipid" and "rvipid" to just "local target" because you don't need two different variables as they're in IFs so it's impossible to have both at same time and different. Therefore it's better to have one local variable.

old Re: Will this work?

Louie
User Off Offline

Quote
@user Rainoth: I can't just test it,and not many players come to my server,and surely i can't test it on Bots
1
2
local vipid = txt:sub(10,#txt)
local rvipid = txt:sub(10,#txt)
so i just put the 'local' near the variables?

old Re: Will this work?

Rainoth
Moderator Off Offline

Quote
Eh... you missed the point. Well whatever, it should work that way too. Yes, add locals as it helps.

old Re: Will this work?

Louie
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
addhook("say","ownersay")
function ownersay(id,txt)
   for _, usgn in ipairs(OWNER) do
      if player(id,'usgn') == usgn then
         if Tag[id] == 1 then 
            msg(Color[id]..""..player(id,"name").."[Owner]: "..txt) 
            return 1
         end
      end
   end
end
I used cs2d lua hook say
I don't get it tho,even if i put "return 1" it still shows the original message so the chat would look like:
Player[Owner]:wtf
Player:wtf
but it should be:
Player[Owner]:wtf

old Re: Will this work?

Rainoth
Moderator Off Offline

Quote
That's because you're using multiple 'say' hooks. Use one hook for all commands and you won't have any problems.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview