Jump to content

[HELP] fail > spawnPlayer


Kapupc

Recommended Posts

i'm so tried because setPlayerTeam still work fine but have no idea about spawnPlayer

when i logged in and camera is fade fine but my ped doesn't spawn i did try to force spawnPlayer in that line but still return false help pls

function tryToLogInAsClient(theLogin,thePassword) 
    if getElementData(source, "IsLoggedIn") == false then 
        if theLogin and thePassword then 
            dbQuery( function(qh, source) 
                        local result = dbPoll( qh, 0 ) 
                        if #result == 1 then 
                            setTimer(triggerClientEvent, 2000, 1, source,"onClientSuccessfullyLogIn",source) 
                            displayServerMessage(source,"you are logged in") 
                            local preData = { 
                                ID = tonumber(result[1].id), 
                                name = result[1].name, 
                                adminlevel = tonumber(result[1].adminlevel), 
                                level = tonumber(result[1].level), 
                                faction = tonumber(result[1].faction), 
                                skinid = tonumber(result[1].skinid), 
                                money = tonumber(result[1].money) 
                            } 
                            playerData[source] = preData 
                            local currentName = getPlayerName(source) 
                            if currentName ~= playerData[source].name then setPlayerName(source, playerData[source].name) end 
                            outputDebugString(currentName.." login with "..theLogin.." account.") 
                            resetPlayerMoney(source) 
                            setPlayerToSpawn(source) -- THIS LINE !! 
                            if playerData[source].faction == 1 then setPlayerTeam(source, civTeam) 
                            elseif playerData[source].faction == 2 then setPlayerTeam(source, policeTeam) 
                            elseif playerData[source].faction == 3 then setPlayerTeam(source, fbiTeam) 
                            elseif playerData[source].faction == 4 then setPlayerTeam(source, marines) 
                            elseif playerData[source].faction == 5 then setPlayerTeam(source, mayorTeam) 
                            elseif playerData[source].faction == 6 then setPlayerTeam(source, reporterTeam) 
                            elseif playerData[source].faction == 7 then setPlayerTeam(source, medicTeam) 
                            elseif playerData[source].faction == 8 then setPlayerTeam(source, licenseTeam) 
                            elseif playerData[source].faction == 9 then setPlayerTeam(source, taxiTeam) 
                            elseif playerData[source].faction == 10 then setPlayerTeam(source, cluckinbellTeam) 
                            elseif playerData[source].faction == 11 then setPlayerTeam(source, vagosTeam) 
                            elseif playerData[source].faction == 12 then setPlayerTeam(source, aztecasTeam) 
                            elseif playerData[source].faction == 13 then setPlayerTeam(source, ballasTeam) 
                            elseif playerData[source].faction == 14 then setPlayerTeam(source, groovstreetTeam) 
                            elseif playerData[source].faction == 15 then setPlayerTeam(source, yakuzaTeam) 
                            elseif playerData[source].faction == 16 then setPlayerTeam(source, lcnTeam) 
                            end                      
                            setElementData(source, "level", playerData[source].level) 
                            triggerClientEvent(source, "doScoreboardAddColumn", source, "level", 40, "Level", 2) 
                            triggerClientEvent(source, "startBind", source) 
  
                            setElementData(source, "IsLoggedIn", true) 
                        else 
                            displayServerMessage(source,"wrong password","warning") 
                        end 
                     end 
                     ,{ source }, mySQL, "SELECT * FROM players WHERE name=? AND password=? LIMIT 1", theLogin, hash("sha512", thePassword)) 
        end 
    end 
end 
addEvent("onClientWantToLogIn",true) 
addEventHandler("onClientWantToLogIn",getRootElement(),tryToLogInAsClient) 

function setPlayerToSpawn(source) 
    local spX, spY, spZ, spA, spI 
    local faction = playerData[source].faction 
    local skin = playerData[source].skinid 
    if faction == 1 then--civ 
        spX = -2047.15 
        spY = -86.17 
        spZ = 35.16 
        spA = 0 
        spI = 0 
    elseif faction == 2 then--police 
        spX = 246.48 
        spY = 121.31 
        spZ = 1003.22 
        spA = 0 
        spI = 10 
    elseif faction == 3 then--fbi 
        spX = 268.29 
        spY = 185.07 
        spZ = 1008.17 
        spA = 0 
        spI = 3 
    elseif faction == 4 then--soldier 
        spX = -1429.62 
        spY = 507.11 
        spZ = 3.03 
        spA = 0 
        spI = 0 
    elseif faction == 5 then--major 
        spX = 347.82 
        spY = 162.06 
        spZ = 1025.78 
        spA = 0 
        spI = 3 
    elseif faction == 6 then--reporter 
        spX = 1719.05 
        spY = -1658.70 
        spZ = 20.22 
        spA = 0 
        spI = 18 
    elseif faction == 7 then--medic 
        spX = -2655.42 
        spY = 636.88 
        spZ = 14.45 
        spA = 0 
        spI = 0 
    elseif faction == 8 then--license 
        spX = -2023.08 
        spY = -114.21 
        spZ = 1035.17 
        spA = 0 
        spI = 3 
    elseif faction == 9 then--taxi 
        spX = -2055.33 
        spY = 8.61 
        spZ = 32.35 
        spA = 0 
        spI = 0 
    elseif faction == 10 then--cluckin bell 
        spX = 377.08 
        spY = -8.26 
        spZ = 1001.85 
        spA = 0 
        spI = 9 
    elseif faction == 11 then--vagos 
        spX = 2246.50 
        spY = -1163.21 
        spZ = 1029.79 
        spA = 0 
        spI = 15 
    elseif faction == 12 then--aztecas 
        spX = 309.26 
        spY = 1123.77 
        spZ = 1083.88 
        spA = 0 
        spI = 5 
    elseif faction == 13 then--ballas 
        spX = 2579.11 
        spY = -1284.45 
        spZ = 1065.36 
        spA = 0 
        spI = 2 
    elseif faction == 14 then--groov street 
        spX = 2448.35 
        spY = -1705.59 
        spZ = 1013.5 
        spA = 0 
        spI = 2 
    elseif faction == 15 then--yakuza 
        spX = -2170.28 
        spY = 646.60 
        spZ = 1057.59 
        spA = 0 
        spI = 1 
    elseif faction == 16 then--lcn 
        spX = 1292.33 
        spY = -825.88 
        spZ = 1085.63 
        spA = 0 
        spI = 5 
    end 
    spawnPlayer( source, spX, spY, spZ, spA, skin, spI) 
    fadeCamera (source, true, 1.5) 
    setCameraTarget (source, source) 
    if spI ~= 0 then 
        setPlayerHudComponentVisible ( source, "radar", false ) 
    else 
        setPlayerHudComponentVisible ( source, "radar", true ) 
    end 
end 

Link to comment

try to change

spawnPlayer( source, spX, spY, spZ, spA, skin, spI)

to

spawnPlayer( source, 0, 0, 0, 0, 0)

if it worked then there is something wrong.

or you can just do:

setElementPosition(source,spX,spY,spZ)

setPedRotation(source,spA)

setElementModel(source,skin)

setElementInterior(source,spI)

also do in setPlayerToSpawn:

outPutDebugString("SpawnPlayer "..getPlayerName(source)".. ") so we can make sure that everything works fine

Link to comment

spawnPlayer (source, 0,0,0,0) from you that work !

but i back to my algorithm and output the check variable is shown fine

but. what can i do

function tryToLogInAsClient(theLogin,thePassword) 
    if getElementData(source, "IsLoggedIn") == false then 
        if theLogin and thePassword then 
            dbQuery( function(qh, thePlayer) 
                        local result = dbPoll( qh, 0 ) 
                        if #result == 1 then 
                            setTimer(triggerClientEvent, 2000, 1, thePlayer,"onClientSuccessfullyLogIn",thePlayer) 
                            displayServerMessage(thePlayer,"you are logged in") 
                            local preData = { 
                                ID = tonumber(result[1].id), 
                                name = result[1].name, 
                                adminlevel = tonumber(result[1].adminlevel), 
                                level = tonumber(result[1].level), 
                                faction = tonumber(result[1].faction), 
                                skinid = tonumber(result[1].skinid), 
                                money = tonumber(result[1].money) 
                            } 
                            playerData[thePlayer] = preData 
                            local currentName = getPlayerName(thePlayer) 
                            if currentName ~= playerData[thePlayer].name then setPlayerName(thePlayer, playerData[thePlayer].name) end 
                            outputDebugString(currentName.." login with "..theLogin.." account.") 
                            resetPlayerMoney(thePlayer) 
                            setPlayerToSpawn(thePlayer) 
                            if playerData[thePlayer].faction == 1 then setPlayerTeam(thePlayer, civTeam) 
                            elseif playerData[thePlayer].faction == 2 then setPlayerTeam(thePlayer, policeTeam) 
                            elseif playerData[thePlayer].faction == 3 then setPlayerTeam(thePlayer, fbiTeam) 
                            elseif playerData[thePlayer].faction == 4 then setPlayerTeam(thePlayer, marines) 
                            elseif playerData[thePlayer].faction == 5 then setPlayerTeam(thePlayer, mayorTeam) 
                            elseif playerData[thePlayer].faction == 6 then setPlayerTeam(thePlayer, reporterTeam) 
                            elseif playerData[thePlayer].faction == 7 then setPlayerTeam(thePlayer, medicTeam) 
                            elseif playerData[thePlayer].faction == 8 then setPlayerTeam(thePlayer, licenseTeam) 
                            elseif playerData[thePlayer].faction == 9 then setPlayerTeam(thePlayer, taxiTeam) 
                            elseif playerData[thePlayer].faction == 10 then setPlayerTeam(thePlayer, cluckinbellTeam) 
                            elseif playerData[thePlayer].faction == 11 then setPlayerTeam(thePlayer, vagosTeam) 
                            elseif playerData[thePlayer].faction == 12 then setPlayerTeam(thePlayer, aztecasTeam) 
                            elseif playerData[thePlayer].faction == 13 then setPlayerTeam(thePlayer, ballasTeam) 
                            elseif playerData[thePlayer].faction == 14 then setPlayerTeam(thePlayer, groovstreetTeam) 
                            elseif playerData[thePlayer].faction == 15 then setPlayerTeam(thePlayer, yakuzaTeam) 
                            elseif playerData[thePlayer].faction == 16 then setPlayerTeam(thePlayer, lcnTeam) 
                            end                      
                            setElementData(thePlayer, "level", playerData[thePlayer].level) 
                            triggerClientEvent(thePlayer, "doScoreboardAddColumn", thePlayer, "level", 40, "Level", 2) 
                            triggerClientEvent(thePlayer, "startBind", thePlayer) 
  
                            setElementData(thePlayer, "IsLoggedIn", true) 
                        else 
                            displayServerMessage(thePlayer,"wrong password","warning") 
                        end 
                     end 
                     ,{ source }, mySQL, "SELECT * FROM players WHERE name=? AND password=? LIMIT 1", theLogin, hash("sha512", thePassword)) 
        end 
    end 
end 
addEvent("onClientWantToLogIn",true) 
addEventHandler("onClientWantToLogIn",getRootElement(),tryToLogInAsClient) 

function setPlayerToSpawn(thePlayer) 
    local spX, spY, spZ, spA, spI 
    local faction = playerData[thePlayer].faction 
    local skin = playerData[thePlayer].skinid 
    if faction == 1 then--civ 
        spX = -2047.15 
        spY = -86.17 
        spZ = 35.16 
        spA = 0 
        spI = 0 
    elseif faction == 2 then--police 
        spX = 246.48 
        spY = 121.31 
        spZ = 1003.22 
        spA = 0 
        spI = 10 
    elseif faction == 3 then--fbi 
        spX = 268.29 
        spY = 185.07 
        spZ = 1008.17 
        spA = 0 
        spI = 3 
    elseif faction == 4 then--soldier 
        spX = -1429.62 
        spY = 507.11 
        spZ = 3.03 
        spA = 0 
        spI = 0 
    elseif faction == 5 then--major 
        spX = 347.82 
        spY = 162.06 
        spZ = 1025.78 
        spA = 0 
        spI = 3 
    elseif faction == 6 then--reporter 
        spX = 1719.05 
        spY = -1658.70 
        spZ = 20.22 
        spA = 0 
        spI = 18 
    elseif faction == 7 then--medic 
        spX = -2655.42 
        spY = 636.88 
        spZ = 14.45 
        spA = 0 
        spI = 0 
    elseif faction == 8 then--license 
        spX = -2023.08 
        spY = -114.21 
        spZ = 1035.17 
        spA = 0 
        spI = 3 
    elseif faction == 9 then--taxi 
        spX = -2055.33 
        spY = 8.61 
        spZ = 32.35 
        spA = 0 
        spI = 0 
    elseif faction == 10 then--cluckin bell 
        spX = 377.08 
        spY = -8.26 
        spZ = 1001.85 
        spA = 0 
        spI = 9 
    elseif faction == 11 then--vagos 
        spX = 2246.50 
        spY = -1163.21 
        spZ = 1029.79 
        spA = 0 
        spI = 15 
    elseif faction == 12 then--aztecas 
        spX = 309.26 
        spY = 1123.77 
        spZ = 1083.88 
        spA = 0 
        spI = 5 
    elseif faction == 13 then--ballas 
        spX = 2579.11 
        spY = -1284.45 
        spZ = 1065.36 
        spA = 0 
        spI = 2 
    elseif faction == 14 then--groov street 
        spX = 2448.35 
        spY = -1705.59 
        spZ = 1013.5 
        spA = 0 
        spI = 2 
    elseif faction == 15 then--yakuza 
        spX = -2170.28 
        spY = 646.60 
        spZ = 1057.59 
        spA = 0 
        spI = 1 
    elseif faction == 16 then--lcn 
        spX = 1292.33 
        spY = -825.88 
        spZ = 1085.63 
        spA = 0 
        spI = 5 
    end 
    outputDebugString( spX ) 
    outputDebugString( spY ) 
    outputDebugString( spZ ) 
    outputDebugString( spA ) 
    outputDebugString( spI ) 
    outputDebugString( skin ) 
    outputDebugString("SpawnPlayer "..getPlayerName(thePlayer)..".. ") 
    spawnPlayer( thePlayer, spX, spY, spZ, spA, skin, spI) 
    fadeCamera (thePlayer, true, 1.5) 
    setCameraTarget (thePlayer, thePlayer) 
    if spI ~= 0 then 
        setPlayerHudComponentVisible ( thePlayer, "radar", false ) 
    else 
        setPlayerHudComponentVisible ( thePlayer, "radar", true ) 
    end 
end 

Link to comment

here is result from log everything fine but ped doesn't spawn :shock:

[2014-12-22 20:21:46] INFO: Jayz_Chou login with Jayz_Chou account.

[2014-12-22 20:21:46] INFO: -2047.15

[2014-12-22 20:21:46] INFO: -86.17

[2014-12-22 20:21:46] INFO: 35.16

[2014-12-22 20:21:46] INFO: 0

[2014-12-22 20:21:46] INFO: 0

[2014-12-22 20:21:46] INFO: 3

[2014-12-22 20:21:46] INFO: SpawnPlayer Jayz_Chou..

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...