• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

Check for required value in database to enter area!

Status
Not open for further replies.

OMGhixD

Sexy Member
So i want a script that looks for the value "1" in characters.premium table

and if the account has that value then he MAY ENTER THE AREA
ifnot he gets teleporter to

{"Mall", 530, -1863, 5430, -9.70, 0},

Would be awesome if some of you guys could help me with this <3
 

Kaev

Super Moderator
I can do it for you, when i'm home in some hours.
Can you give me the zone or area id (hope you know the difference :s ) of the mall?
 

OMGhixD

Sexy Member
I can do it for you, when i'm home in some hours.
Can you give me the zone or area id (hope you know the difference :s ) of the mall?

ohh yah i know the difference! :D

i'm gonna give you the most important GPS information :)

Map: 530 (Outland) Zone: 3518 Area: 3631
X: -2766.928467 Y: 8346.442383 Z -88.771057 Orientation: 3.789816

Zonex: 35.283089 ZoneY: 76.251457

hope this helps :)
 

Tommy

Founder
Querying is pretty simple. Have you actually tried it yourself? You might learn more doing so.

LuaFunctions.cpp (Methods, etc) and HookMgr.h (Hooks, event #, etc) can help you if needed, just need to look through it.

I made a script for you. Though, if there's issues with it someone else could help you fix them or I can if nobody has.

Code:
local function PlayerUpdateZone(event, player, newZone, newArea)
    if (newZone == 3518 and newArea == 3631) then
        local result = CharDBQuery("SELECT columnVal FROM premium WHERE acctId='"..player:GetAccountId().."'") -- Change columnVal to the column we're pulling the 'value 1' from. Also change 'acctId' column name to the appropriate column name that is in your table
        local val = result:GetBool(0)
        if not val then
            player:TeleportTo(530, x, y, z, o) -- Change x, y, z, o to the location you want to send them
            player:SendNotification("You cannot come to this zone/area!")
        end
    end
end

RegisterPlayerEvent(27, PlayerUpdateZone)

I'm not too comfortable using the CharDBQuery in that certain event because it will be used every time someone goes into that zone/area. Would be best to create a table and adding the premium column values in there at server start up. HOWEVER, you did NOT give enough information about the table so I cannot help you doing that until you can supply the table structure. Make sure to read the comments I left in the script. Enjoy.
 

OMGhixD

Sexy Member
Querying is pretty simple. Have you actually tried it yourself? You might learn more doing so.

LuaFunctions.cpp (Methods, etc) and HookMgr.h (Hooks, event #, etc) can help you if needed, just need to look through it.

I made a script for you. Though, if there's issues with it someone else could help you fix them or I can if nobody has.

Code:
local function PlayerUpdateZone(event, player, newZone, newArea)
    if (newZone == 3518 and newArea == 3631) then
        local result = CharDBQuery("SELECT columnVal FROM premium WHERE acctId='"..player:GetAccountId().."'") -- Change columnVal to the column we're pulling the 'value 1' from. Also change 'acctId' column name to the appropriate column name that is in your table
        local val = result:GetBool(0)
        if not val then
            player:TeleportTo(530, x, y, z, o) -- Change x, y, z, o to the location you want to send them
            player:SendNotification("You cannot come to this zone/area!")
        end
    end
end

RegisterPlayerEvent(27, PlayerUpdateZone)

I'm not too comfortable using the CharDBQuery in that certain event because it will be used every time someone goes into that zone/area. Would be best to create a table and adding the premium column values in there at server start up. HOWEVER, you did NOT give enough information about the table so I cannot help you doing that until you can supply the table structure. Make sure to read the comments I left in the script. Enjoy.

Thank you tommy, i will definetly try to do this myself next time <3!
 
Status
Not open for further replies.
Top