esporta05 Posted July 28, 2014 Share Posted July 28, 2014 Okay i need to make a if statement to find if the player is in a specified table or not. Here is the script that I made. Is this ok? local vips = } [1]=”Anubhav”, [2]=”esporta”, } if (thePlayer == vips) then outPutChatBox ("You are vip", source) else outPutChatBox("You are not a vip", source) end end Link to comment
AboShanab Posted July 28, 2014 Share Posted July 28, 2014 in table name player account or player name ? Link to comment
esporta05 Posted July 28, 2014 Author Share Posted July 28, 2014 If the player account name is included in table, script will output you are vip if not script will output you aren't vip Link to comment
Et-win Posted July 28, 2014 Share Posted July 28, 2014 vips = { "Anubhav", "esporta", } local gPlayers = getElementsByType("player") for placeNumber, playerData in ipairs(gPlayers) do local gAccount = getPlayerAccount(playerData) if (gAccount ~= false) and (isGuestAccount(playerData) == false) then local gAccountName = getAccountName(gAccount) if (gAccountName ~= false) then local isVip = false for placeNumber2, stringData in ipairs(vips) do if (gAccountName == stringData) then isVip = true end end if (isVip == true) then outputChatBox("You are a vip.", playerData) elseif (isVip == false) then outputChatBox("You are not a vip.", playerData) end end end end Serverside and for all players. If you want it for 1 player only, you can edit the script. Link to comment
esporta05 Posted July 28, 2014 Author Share Posted July 28, 2014 Is it so hard do detect if the logged in player account name is contained in that table? Because I don't understand anything. I am just trying to detect if the logged in player is registered in that vips table. Btw there is no guest accounts on server. They are supposed to login in order to play server. Isn't it possible like this: vips = { "Anubhav", "esporta", "bilal", } local accname = getAccountName (source) if (accname == vips) then --script body end Link to comment
Et-win Posted July 28, 2014 Share Posted July 28, 2014 There is a guest account on every server. You have to unpack the table anyway to check it. Otherwise, use set/getElement/AccountData Link to comment
Cadu12 Posted July 28, 2014 Share Posted July 28, 2014 local vips = { "Anubhav", "esporta", "bilal", } local accname = getAccountName(source) if (vips[accname]) then outputChatBox ("You are vip", source) else outputChatBox("You are not a vip", source) end Link to comment
RottenFlesh Posted July 28, 2014 Share Posted July 28, 2014 vips = { "someguy", "otherguy", "anotherone" } function on_login (_, new_acc) local acc_name = getAccountName(new_acc) for i,vip_acc_name in ipairs(vips) do if acc_name == vip_acc_name then outputChatBox("Wellcome to your vip account.", source, 255, 255, 255, true) return true end end outputChatBox("You are not vip", source, 255, 255, 255, true) end addEventHandler('onPlayerLogin', root, on_login) i have not tested this. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now