Jump to content

xUltimate

Members
  • Posts

    92
  • Joined

  • Last visited

Posts posted by xUltimate

  1. Using Paradise Roleplay script, I removed the SHA1 and SALT from it but now the login won't work and it keeps printing out Incorrect Username or Password.

    addEvent( getResourceName( resource ) .. ":login", true ) 
    addEventHandler( getResourceName( resource ) .. ":login", root, 
        function( username, password ) 
            if source == client then 
                triedTokenAuth[ source ] = true 
                if username and password and #username > 0 and #password > 0 then 
                    local info = exports.sql:query_assoc_single( "SELECT username, password AS token FROM wcf1_user WHERE `username` = '%s' AND password = '".. password .. "'", getPlayerHash( source ) ) 
                    p[ source ] = nil 
                    if not info then 
                        triggerClientEvent( source, getResourceName( resource ) .. ":loginResult", source, 1 ) -- Wrong username/password 
                        loginAttempts[ source ] = ( loginAttempts[ source ] or 0 ) + 1 
                        if loginAttempts[ source ] >= 5 then 
                            kickPlayer( source, true, false, false, root, "Too many login attempts.", 900 ) 
                        end 
                    else 
                        loginAttempts[ source ] = nil 
                        performLogin( source, info.token, true ) 
                    end 
                end 
            end 
        end 
    ) 
      
    function performLogin( source, token, isPasswordAuth, ip, username ) 
        if source and ( isPasswordAuth or not triedTokenAuth[ source ] ) then 
            triedTokenAuth[ source ] = true 
            if token then 
                if #token == 80 then 
                    local info = exports.sql:query_assoc_single("SELECT userID, CONCAT(username, '%s'), banned, activationCode, password AS userOptions FROM wcf1_user WHERE username = '%s' LIMIT 1", getPlayerHash(source)) 
                    p[ source ] = nil 
                    if not info then 
                        if isPasswordAuth then 
                            triggerClientEvent( source, getResourceName( resource ) .. ":loginResult", source, 1 ) -- Wrong username/password 
                        end 
                        return false 
                    else 
                        if info.banned == 1 then 
                            triggerClientEvent( source, getResourceName( resource ) .. ":loginResult", source, 2 ) -- Banned 
                            return false 
                        elseif info.activationCode > 0 then 
                            triggerClientEvent( source, getResourceName( resource ) .. ":loginResult", source, 3 ) -- Requires activation 
                            return false 
                        else 
                            -- check if another user is logged in on that account 
                            for player, data in pairs( p ) do 
                                if data.userID == info.userID then 
                                    triggerClientEvent( source, getResourceName( resource ) .. ":loginResult", source, 5 ) -- another player with that account found 
                                    return false 
                                end 
                            end 
                            local username = info.username 
                            p[ source ] = { userID = info.userID, username = username, options = info.userOptions and fromJSON( info.userOptions ) or { } } 
                             
                            -- check for admin rights 
                            aclUpdate( source, true ) 
                             
                            -- show characters 
                            local chars = exports.sql:query_assoc( "SELECT characterID, characterName, skin FROM characters WHERE userID = " .. info.userID .. " ORDER BY lastLogin DESC" ) 
                            if isPasswordAuth then 
                                triggerClientEvent( source, getResourceName( resource ) .. ":characters", source, chars, true, token, getPlayerIP( source ) ~= "127.0.0.1" and getPlayerIP( source ) ) 
                            else 
                                triggerClientEvent( source, getResourceName( resource ) .. ":characters", source, chars, true ) 
                            end 
                             
                            outputServerLog( "Rockstar Roleplay: Login " .. getPlayerName( source ) .. " logged in as " .. info.username .. " (IP: " .. getPlayerIP( source ) .. ", Serial: " .. getPlayerSerial( source ) .. ")" ) 
                            exports.server:message( "%C04[" .. getID( source ) .. "]%C %B" .. info.username .. "%B logged in (Nick: %B" .. getPlayerName( source ):gsub( "_", " " ) .. "%B)." ) 
                            exports.sql:query_free( "UPDATE wcf1_user SET lastIP = '%s', lastSerial = '%s' WHERE userID = " .. tonumber( info.userID ), getPlayerIP( source ), getPlayerSerial( source ) ) 
                             
                            return true 
                        end 
                    end 
                end 
            end 
        end 
        return false 
    end 
    

  2. Also, you don't need those "and"s, eg you have

    function TruckerPoint ( thePlayer ) 
            if getElementType ( thePlayer ) == "player" then 
            givePlayerMoney ( thePlayer, 750 ) 
            and outputChatbox ( "Danke für die Lieferung! Dein Lohn: 750$") 
            and setElementposition ( thePlayer 197, 1880, 11 ) 
    end[/lua 
      
    and it should be 
      
    [lua]function TruckerPoint ( thePlayer ) 
            if getElementType ( thePlayer ) == "player" then 
            givePlayerMoney ( thePlayer, 750 ) 
            outputChatbox ( "Danke für die Lieferung! Dein Lohn: 750$") 
            setElementposition ( thePlayer 197, 1880, 11 ) 
    end 
    

    and what's this? creating a function within a created function?

    Use this

    TruckerIn = createMarker(1087, 1895, 11, "cylinder", 1.5, 255, 0, 0, 150) 
    function Truckerjob() 
        NewMarker = createMarker ( 2755, -2464, 14 "cylinder", 1.5, 255, 0, 0, 150 ) 
        NewBlip = createBlip ( 2755, -2464, 14, 51, 1, 255, 0, 0, 0, 255 ) 
    end 
    addEventHandler ( "onResourceStart",Truckerjob, TruckerIn ) 
      
    function TruckerTel(thePlayer) 
        if getElementType ( thePlayer ) == "player" then 
        setElementPosition ( thePlayer 1095, 1880, 11 ) 
        createVehicle ( 432, 1098, 1880, 11 ) 
        outputChatBox ( "Steig in den LKW!" ) 
    end 
    addEventHandler ("onMarkerHit", TruckerIn, TruckerTel) 
      
    function TruckerPoint ( thePlayer ) 
        if getElementType ( thePlayer ) == "player" then 
            givePlayerMoney ( thePlayer, 750 ) 
            outputChatbox ( "Danke für die Lieferung! Dein Lohn: 750$") 
            setElementposition ( thePlayer 197, 1880, 11 ) 
        end 
    addEventHandler ( "onMarkerHit", NewMarker, TruckerPoint ) 
    

  3. Could be the fact that your defining a and b twice, try using something like

    a = 1 
    b = 99999999 
    outputChatBox ( a + b ) -->100000000 
    outputChatBox ( 1 + 99999999 ) -->100000000 
    --------------------------------------------------------------- 
    c = 2 
    outputChatBox ( c + b ) -->100000000 --wth? 
    outputChatBox ( 2 + 99999999 ) -->100000001 
    

  4. Alright, i'll make a bug report, I posted it here though because I saw a post of this somewhere and I found it weird that I was the only person getting the bug.

    EDIT: When I started my game again today it wasn't doing this anymore, I will still make a bug report about this though.

  5. Whenever I type in the chatbox if I try to say "hi" it puts "hhii" but in the console is just fine, I noticed a post about this before, it worked fine in MTA 1.0.4 but when I upgraded to 1.1 it does this now and for my friend it's not doing this.

  6. updateNametagColor calls for a getOption and setOption function, i tried working with your system but it's a little complicated when it comes to PRP's getOption and setOption

    addCommandHandler( "duty", 
        function( thePlayer, commandName ) 
            if exports.players:isLoggedIn( thePlayer ) then 
                if isPlayerInFactionType( thePlayer, 1 ) then 
                    if getElementData(thePlayer, "dutyOn") == true then 
                        takeWeapon( thePlayer, 41 ) 
                        setPedArmor( thePlayer, 0 ) 
                        setPlayerNametagColor( thePlayer, 255, 255, 255 ) 
                        outputChatBox("You are no longer on duty.", thePlayer, 255, 255, 255 ) 
                        setElementData(thePlayer, "dutyOn", false) 
                    else 
                        giveWeapon( thePlayer, 41, 500 ) 
                        setPedArmor( thePlayer, 100 ) 
                        setPlayerNametagColor( thePlayer, 0, 0, 255 ) 
                        outputChatBox("You are now on duty.", thePlayer, 255, 255, 255 ) 
                        setElementData(thePlayer, "dutyOn", true) 
                    end 
                end 
            end 
        end 
    ) 
    

    Is how far I got with it.

  7. Oh sh*t, I forgot about that haha. Going to change it to trigger serverside.

    EDIT: Ok did that but now it just does nothing. :|

    Client:

    carshop = createMarker(1751.32, -2055.36, 12.71, "cylinder", 1, 0, 255, 0, 180) 
    carshopcol = createColSphere ( 1751.32, -2055.36, 13.71, 1 ) 
    local cars = { 400, 401, 402, 404, 405, 409, 410, 411 } 
    local prices = { 5995, 4995, 6995, 3495, 7999, 34995, 7995, 125000 } 
      
    addEventHandler("onClientResourceStart", resourceRoot, 
        function() 
            Window = {} 
            Button = {} 
            Grid = {} 
            Window[1] = guiCreateWindow(558, 219, 302, 324, "Los Santos Car Shop", false) 
            Grid[1] = guiCreateGridList(10, 26, 283, 244, false, Window[1]) 
            guiGridListSetSelectionMode(Grid[1], 2) 
            local column1 = guiGridListAddColumn(Grid[1], "Vehicle", 0.50) 
            local column2 = guiGridListAddColumn(Grid[1], "Price", 0.40) 
            if (column1 and column2) then 
                for a = 1,#cars do 
                    local name = getVehicleNameFromModel(cars[a]) 
                    local prices = tostring(prices[a]) 
                    local row = guiGridListAddRow(Grid[1]) 
                    if name ~= "" then 
                        guiGridListSetItemText(Grid[1], row, column1, name, false, false) 
                        guiGridListSetItemText(Grid[1], row, column2, prices, false, false) 
                    end 
                end 
            end 
            Button[1] = guiCreateButton(17, 295, 73, 20, "Purchase", false, Window[1]) 
            Button[2] = guiCreateButton(219, 294, 73, 20, "Cancel", false, Window[1]) 
            guiSetVisible( Window[1], false ) 
            addEventHandler("onClientGUIClick", Button[1], callServerPurchase, false ) 
            addEventHandler("onClientGUIClick", Button[2], hideGUI, false ) 
        end 
    ) 
      
    function showGUI() 
        guiSetVisible( Window[1], true ) 
    end 
    addEventHandler("onClientColShapeHit",getRootElement(),showGUI) 
      
    function hideGUI() 
        guiSetVisible( Window[1], false ) 
    end 
      
    function callServerPurchase() 
        local sig = guiGridListGetSelectedItem(Grid[1]) 
        local price = tonumber(guiGridListGetItemText(Grid[1], sig, column2)) 
        local car = guiGridListGetItemText(Grid[1], sig1, column1) 
        setElementData(source, "price", price) 
        setElementData(source, "thecar", car) 
        triggerServerEvent( "purchaseCar", source ) 
        guiSetVisible( Window[1], false ) 
    end 
    

    Server:

    addEvent( "purchaseCar", true ) 
    addEventHandler( "purchaseCar", root, 
        function (source) 
            local price = getElementData(source, "price") 
            local car = getElementData(source, "thecar") 
            if exports.players:takeMoney(source, price) then 
                -- try to create a permanent one 
                local vehicle, vehicleID = exports.vehicles:create(source, car) 
                if vehicle then 
                    local vehname = getVehicleName(vehicle) 
                    outputChatBox( "Congratulations! You've bought a " .. vehname .. "!", source, 255, 127, 0 ) 
                    outputChatBox( "Remember to use /park to set a permanent spawn position for this vehicle.", source, 255, 255, 0 ) 
                    spawnVehicle(vehicle, 1758.65, -2056.82, 13.58, 0, 0, 0) 
                    -- give him the keys 
                    exports.items:give( source, 1, vehicleID, vehname ) 
                else 
                    -- failed somewhere 
                    exports.players:giveMoney( source, price ) 
                end 
            else 
                outputChatBox( "A error occured, this was expected.", source, 255, 0, 0 ) 
            end 
        end 
    ) 
    

  8. policeVehicle = createVehicle ( 426, 2401.4436035156, 76.328956604004, 25.292650222778, 0, 0, 90 ) 
    policeSkins = { [286]=true,[288]=true } 
    medicVehicle = createVehicle ( 426, 2418.4436035156, 85.328956604004, 26.292650222778, 0, 0, 90 ) 
    medicSkins = { [275]=true,[277]=true } 
      
    function enterVehicle ( player, seat, jacked ) 
        if (getElementModel( source ) ==  getElementModel(policeVehicle) ) and ( not policeSkins[getElementModel( player )] ) then 
            outputChatBox ( "You're not a cop!", player ) 
            cancelEvent() 
        elseif(getElementModel( source ) ==  getElementModel(medicVehicle) ) and ( not medicSkins[getElementModel( player )] ) then 
            outputChatBox ( "You're not a medic!", player ) 
            cancelEvent() 
        end 
    end 
    addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 
    

    Try that.

  9. This should work

    addCommandHandler( "setskin", 
        function( skin ) 
            skin = tonumber( skin ) 
            local oldSkin = getElementModel( source ) 
            if oldSkin == skin then 
                outputChatBox( name .. " is already using that skin.", source, 255, 255, 0 ) 
            elseif setElementModel( source, skin ) then 
                outputChatBox( "Set " .. name .. "'s skin to " .. skin, source, 0, 255, 153 ) 
            else 
                outputChatBox( "Skin " .. skin .. " is invalid.", source, 255, 0, 0 ) 
            end 
        end 
    ) 
    

    Let me know if you have any problems.

×
×
  • Create New...