Jump to content

# ZkillCatIV

Members

14

## Posts posted by ZkillCatIV

### [HELP] I need an explanation in InterpolateBetween Please

On 2/14/2017 at 08:16, pa3ck said:

I see you already found a similar topic and that helped you, but in case you didn't understand interpolation fully, I will explain. So basically it's a function, that increments / decrements gradually between start and endpoints. So if you had 2 camera positions and you wanted to have a nice movement between the 2 positions, you would use interpolation. In theory, it returns a number between -1 and 1 over it's progression. When this curve is over, it will always return 1. Now, in MTA, you can call this function with 3 start and 3 end points and one easing type, which defines the actual curve of progression (take a look at the link in order to better understand them). Although, this "interpolateBetween" function does not remember the progression, it doesn't know whether it's finished, half way through or just started off, that is why you will have couple of variables. getTickCount() is an integer that returns the amount of time your system has been running in milliseconds, so it's unique and can be used to mark different events. For example you can save the starting time with getTickCount and in an event like onClientRender you can compare how many seconds have passed. Thing you will need:

Start time: getTickCount() whenever you call the interpolation first

Elapsed time: current getTickCount() - start time -> returns elapsed time in milliseconds

Duration: how long will it take to reach from start to the end in milliseconds -> probably it won't change

Progress: the current state of the interpolation, to get this, use the formula: elapsedTime / duration

And you will also need 3 start and 3 end points, as I already said (although, if you need only 1 start and 1 end, just use 0's)

To wrap it up, this is how you call interpolateBetween ( remember that you will always want to run it inside render )

```
local start = getTickCount()
function render()
local now = getTickCount()
local endTime = start + 2000
local elapsedTime = now - start
local duration = endTime - start
local progress = elapsedTime / duration
local posX, posY, posZ = interpolateBetween ( startPosX, startPosY, startPosZ, endPosX, endPosY, endPosZ, progress, "Linear")
end
addEventHandler("onClientRender", root, render)
```

ohhhh I understand it now, its so simple but it seems hard thank you so much for your reply. finally understood that function hahhaha really you have no idea how long i have been looking for this answer.

### Move camera

Thank you so much this post helped me 100%

P.S 50p you are awesome dude

### [HELP] I need an explanation in InterpolateBetween Please

Well, I'm trying to move the camera but i dont want to use the object method and I saw that you can do it with interpolatebetween can someone tell me how please

### [HELP] I need an explanation in InterpolateBetween Please

I have an understanding in the topic the only thing that I dont get is the fprogress please can explain me with detail why they use getTickCount() and add subtract and devide to get that progress I just dont get it, thank you...!!!

please not mean comments not everybody is an einstein at everything and dont say look at the wiki the wiki dont explain with details.

### LITTLE HELP PLEASE with interpolateBetween

Thank you so much guys i was doing it with just one dxDrawText using the /n to skip lines but i couldn't get the text to move as i wished to. I tried reading the wiki like 10 times i get the some of the interpolateBetween but i dont get what do i put where it ask me about the x,y,z and the time process but im going to try Thanks Woovie and DealMan .  you guys are the best

### LITTLE HELP PLEASE with interpolateBetween

i need someone to explain me how does interpolateBetween work and how can it be applied and on what please and thank you. i want to make a script that shows credits like in the movies where credits go from the bottom to the top crossing the screen. like that or can someone tell me if its possible PLEASE AND THANK YOU

### I have a question about cameras and objects

OKAY i already fixed the camera but can somebody explain me the interpolateBetween ? Please

### I have a question about cameras and objects

3 minutes ago, Bonsai said:

You will need to do that using the "onClientRender", or better "onClientPreRender" if mouse movement possible, events.

setCameraMatrix only sets the camera to a static position, so you need to update it on every frame.

So i have a login panel on my server,if i do "onClientPreRender" will it be trigger when the player joins also ? Because i wanted to be trigger when the player LogIn

### I have a question about cameras and objects

First of all thanks for taking your time to read this.

Back to the question i wanted to make a script that when someone logsIn the camera targeted an object and follow the object as the object moved instead of targeting the player then when the object stoped that the player spawned there where the object stoped. My idea with this was to make a mini intro. But i can not get the setCameraTarget to go to the object and i tried the setCameraMatrix to the object and it works but when i move the object the camera does not follow i already tried with a setTimer and a function but i cant get it to work

Note : i dont have a script to post

Thanks again for reading this i hope you can help me ☺

### [HELP]

thank you so much dimos7 , the code worked perfectly i appreciate your time and your help. and also thank you so much SuperCorz    for explaining the problem and the solution with great detail thank you guys so much for helping me it works perfect now.

### [HELP]

36 minutes ago, SuperCroz said:

Let me get this straight;

The login panel appears to everyone when it is supposed to appear to one guy? and the changes that are supposed to be changed for one guy is being changed for everyone?

well if a player is on the login panel and have not login account the in the panel will show a message that says "account not found" but if in the process another player joins and has already an account it shows a message saying "account found" but the message from the panel that says "account found " also show on the panel from the other player that says "account not found " if like the gui panel was on the server and not on the players. i think it has to do with to whom i am sending the panel but i am not sure i already tried replacing the getRootElement() to other variables and the panel only shows to the player that join but the changes affect the other players panels too.

### [HELP]

9 minutes ago, Gravestone said:

It's hard for me to read your code like this xd. Since you're new to the forums, you can post your code by clicking on the '<>' option in the taskbar and then select 'lua' and paste your code.

```addEvent("accountFound",true)
addEvent("accountNotFound",true)
addEvent("clientResponse",true)
function playerJoined ()
toggleAllControls(false)
fadeCamera(false)
joinImg = guiCreateStaticImage(0, 0, 1920, 1080, "login.png", false)
loadingText = guiCreateLabel(801, 44, 336, 88, "LOADING ...", false,joinImg)
guiLabelSetHorizontalAlign(loadingText, "center", false)
guiLabelSetVerticalAlign(loadingText, "center")
findingText = guiCreateLabel(801, 44, 336, 88, "FINDING ACCOUNT ...", false,joinImg)
guiSetFont(findingText, "clear-normal")
guiLabelSetHorizontalAlign(findingText, "center", false)
guiLabelSetVerticalAlign(findingText, "center")
guiSetVisible(findingText,false)
local resource = getResourceFromName ( "login" )
local resourceState = getResourceState( resource )
if (resourceState == "running") then
guiSetVisible(loadingText,false)
guiSetVisible(findingText,true)
triggerServerEvent("checkAccounts", localPlayer)
end
end

function playerLogin ()
showCursor(true)
destroyElement(findingText)
foundText = guiCreateLabel(801, 44, 336, 88, "ACCOUNT FOUND ...", false,joinImg)
guiLabelSetHorizontalAlign(foundText, "center", false)
guiLabelSetVerticalAlign(foundText, "center")
userNameTextL = guiCreateLabel(1591, 494, 235, 25, "PLEASE ENTER USERNAME", false, joinImg)
userNameBoxL = guiCreateEdit(1553, 519, 309, 34, "", false, joinImg)
passwordTextL = guiCreateLabel(1591, 639, 235, 25, "PLEASE ENTER PASSWORD", false, joinImg)
passwordBoxL = guiCreateEdit(1553, 664, 309, 34, "", false, joinImg)
enterButtonL = guiCreateButton(1637, 838, 160, 42, "LOGIN", false, joinImg)
addEventHandler("onClientGUIClick",enterButtonL,login,false)

end

function login()
triggerServerEvent("playerLogins",localPlayer,guiGetText(userNameBoxL),guiGetText(passwordBoxL))
guiSetEnabled(enterButtonL,false)
setTimer(guiSetEnabled,3000,1,enterButtonL,true)
end

function playerRegister ()
showCursor(true)
destroyElement(findingText)
unfoundText = guiCreateLabel(801, 44, 336, 88, "ACCOUNT NOT FOUND ...", false,joinImg)
guiLabelSetColor(unfoundText, 255, 67, 67)
guiLabelSetHorizontalAlign(unfoundText, "center", false)
guiLabelSetVerticalAlign(unfoundText, "center")
passwordTextR = guiCreateLabel(1591, 494, 235, 25, "PLEASE ENTER PASSWORD", false, joinImg)
passwordBoxR = guiCreateEdit(1553, 519, 309, 34, "", false, joinImg)
userNameTextR = guiCreateLabel(1591, 359, 235, 25, "PLEASE ENTER USERNAME", false, joinImg)
userNameBoxR = guiCreateEdit(1553, 384, 309, 34, "", false, joinImg)
emailTextR = guiCreateLabel(1591, 639, 235, 25, "PLEASE ENTER EMAIL", false, joinImg)
mailBoxR = guiCreateEdit(1553, 664, 309, 34, "", false, joinImg)
emailTextsR = guiCreateLabel(1563, 708, 289, 59, " * email will be used as a password backup,\n also as a form of security and contact issues. please give your authentic and active email\n Thank you.", false, joinImg)
enterButtonR = guiCreateButton(1637, 838, 160, 42, "", false, joinImg)
addEventHandler("onClientGUIClick",enterButtonR,register,false)
end
function register()
if #guiGetText(userNameBoxR) <= 4 then
guiSetText(unfoundText,"THE USERNAME HAS TO HAVE AT LEAST FIVE LETTERS")
return
end
if #guiGetText(passwordBoxR) <= 4 then
guiSetText(unfoundText,"THE PASSWORD HAS TO HAVE AT LEAST FIVE LETTERS.")
return
end
if #guiGetText(mailBoxR) <= 9 then
guiSetText(unfoundText,"SET AN EMAIL ")
return
else
triggerServerEvent("playerRegisters",localPlayer ,guiGetText(userNameBoxR),guiGetText(passwordBoxR),guiGetText(mailBoxR))
guiSetEnabled(enterButtonR,false)
setTimer(guiSetEnabled,3000,1,enterButtonR,true)
end
end

function loginError( number , errors )
if number == 1 or  number == 2 then
guiSetText(foundText,errors)
elseif number == 4 then
guiSetText(unfoundText,errors)
elseif number == 3 then
destroyElement(joinImg)
showCursor(false)
toggleAllControls(true)
fadeCamera(true,5)
end
end
addEventHandler("onClientResourceStart",  getRootElement(), playerJoined)
addEventHandler("accountFound", getRootElement(), playerLogin)
addEventHandler("accountNotFound", getRootElement(), playerRegister)
addEventHandler("clientResponse", getRootElement(), loginError)

```

that is the client side

```addEvent("checkAccounts",true)
addEvent("playerLogins",true)
addEvent("playerRegisters",true)
function checkingAccounts()
heSerial = getPlayerSerial(client)
accounts = getAccountsBySerial(heSerial)
if (#accounts ~= 0) then
triggerClientEvent("accountFound",client)
else
triggerClientEvent("accountNotFound",client)
end
end

function loginProcces (username , password )
if not getAccount(username) then
triggerClientEvent(client,"clientResponse",client,1 , "INVALID USERNAME")
return
end
if not getAccount(username,password) then
triggerClientEvent(client,"clientResponse",client,2,"INVALID PASSWORD,")
return
end
logIn(client,getAccount(username),password)
triggerClientEvent(client,"clientResponse",client,3)
end

function registerProcces(username, password, email)
if getAccount(username) then
triggerClientEvent(client,"clientResponse",client,4,"THERE IS ANOTHER ACCOUNT WITH THIS NAME TRY SOMETHING NEW ")
return
end
addAccount(username,password)
logIn(client,getAccount(username),password)
setAccountData (getAccount(username),heSerial,password)
setAccountData (getAccount(username),email,username)
triggerClientEvent(client,"clientResponse",client,3)
end
addEventHandler("checkAccounts",getRootElement(),checkingAccounts)
addEventHandler("playerLogins",getRootElement(),loginProcces)
addEventHandler("playerRegisters",getRootElement(),registerProcces)
```

and this is the server side thank you so much for the help

### [HELP]

9 hours ago, ZkillCatIV said:

Im somewhat new in scripting, i was making a login panel  and the login panel is working and i can login and register but the only problem i have is that when i get join and i'm on the login panel and somebody else joins and is on the panel and mess with it my panel also changes,it acts like the login panel was in the server instead of just the player that joins. to be honest i don't really understand the localPlayer and the root and the getRootElement() and all of that but i have a feeling that that is what is going wrong on my script please help me

client side ----------------------------------------

addEvent("accountFound",true)
addEvent("accountNotFound",true)
addEvent("clientResponse",true)
function playerJoined ()
toggleAllControls(false)
fadeCamera(false)
joinImg = guiCreateStaticImage(0, 0, 1920, 1080, "login.png", false)
loadingText = guiCreateLabel(801, 44, 336, 88, "LOADING ...", false,joinImg)
guiLabelSetHorizontalAlign(loadingText, "center", false)
guiLabelSetVerticalAlign(loadingText, "center")
findingText = guiCreateLabel(801, 44, 336, 88, "FINDING ACCOUNT ...", false,joinImg)
guiSetFont(findingText, "clear-normal")
guiLabelSetHorizontalAlign(findingText, "center", false)
guiLabelSetVerticalAlign(findingText, "center")
guiSetVisible(findingText,false)
local resource = getResourceFromName ( "login" )
local resourceState = getResourceState( resource )
if (resourceState == "running") then
guiSetVisible(loadingText,false)
guiSetVisible(findingText,true)
triggerServerEvent("checkAccounts", localPlayer)
end
end

function playerLogin ()
showCursor(true)
destroyElement(findingText)
foundText = guiCreateLabel(801, 44, 336, 88, "ACCOUNT FOUND ...", false,joinImg)
guiLabelSetHorizontalAlign(foundText, "center", false)
guiLabelSetVerticalAlign(foundText, "center")
userNameTextL = guiCreateLabel(1591, 494, 235, 25, "PLEASE ENTER USERNAME", false, joinImg)
userNameBoxL = guiCreateEdit(1553, 519, 309, 34, "", false, joinImg)
passwordTextL = guiCreateLabel(1591, 639, 235, 25, "PLEASE ENTER PASSWORD", false, joinImg)
passwordBoxL = guiCreateEdit(1553, 664, 309, 34, "", false, joinImg)
enterButtonL = guiCreateButton(1637, 838, 160, 42, "LOGIN", false, joinImg)
addEventHandler("onClientGUIClick",enterButtonL,login,false)

end

function login()
triggerServerEvent("playerLogins",localPlayer,guiGetText(userNameBoxL),guiGetText(passwordBoxL))
guiSetEnabled(enterButtonL,false)
setTimer(guiSetEnabled,3000,1,enterButtonL,true)
end

function playerRegister ()
showCursor(true)
destroyElement(findingText)
unfoundText = guiCreateLabel(801, 44, 336, 88, "ACCOUNT NOT FOUND ...", false,joinImg)
guiLabelSetColor(unfoundText, 255, 67, 67)
guiLabelSetHorizontalAlign(unfoundText, "center", false)
guiLabelSetVerticalAlign(unfoundText, "center")
passwordTextR = guiCreateLabel(1591, 494, 235, 25, "PLEASE ENTER PASSWORD", false, joinImg)
passwordBoxR = guiCreateEdit(1553, 519, 309, 34, "", false, joinImg)
userNameTextR = guiCreateLabel(1591, 359, 235, 25, "PLEASE ENTER USERNAME", false, joinImg)
userNameBoxR = guiCreateEdit(1553, 384, 309, 34, "", false, joinImg)
emailTextR = guiCreateLabel(1591, 639, 235, 25, "PLEASE ENTER EMAIL", false, joinImg)
mailBoxR = guiCreateEdit(1553, 664, 309, 34, "", false, joinImg)
emailTextsR = guiCreateLabel(1563, 708, 289, 59, " * email will be used as a password backup,\n also as a form of security and contact issues. please give your authentic and active email\n Thank you.", false, joinImg)
enterButtonR = guiCreateButton(1637, 838, 160, 42, "", false, joinImg)
addEventHandler("onClientGUIClick",enterButtonR,register,false)
end
function register()
if #guiGetText(userNameBoxR) <= 4 then
guiSetText(unfoundText,"THE USERNAME HAS TO HAVE AT LEAST FIVE LETTERS")
return
end
if #guiGetText(passwordBoxR) <= 4 then
guiSetText(unfoundText,"THE PASSWORD HAS TO HAVE AT LEAST FIVE LETTERS.")
return
end
if #guiGetText(mailBoxR) <= 9 then
guiSetText(unfoundText,"SET AN EMAIL ")
return
else
triggerServerEvent("playerRegisters",localPlayer ,guiGetText(userNameBoxR),guiGetText(passwordBoxR),guiGetText(mailBoxR))
guiSetEnabled(enterButtonR,false)
setTimer(guiSetEnabled,3000,1,enterButtonR,true)
end
end

function loginError( number , errors )
if number == 1 or  number == 2 then
guiSetText(foundText,errors)
elseif number == 4 then
guiSetText(unfoundText,errors)
elseif number == 3 then
destroyElement(joinImg)
showCursor(false)
toggleAllControls(true)
fadeCamera(true,5)
end
end
addEventHandler("onClientResourceStart",  getRootElement(), playerJoined)
addEventHandler("accountFound", getRootElement(), playerLogin)
addEventHandler("accountNotFound", getRootElement(), playerRegister)
addEventHandler("clientResponse", getRootElement(), loginError)

server side---------------------------------------------------------------

addEvent("checkAccounts",true)
addEvent("playerLogins",true)
addEvent("playerRegisters",true)
function checkingAccounts()
heSerial = getPlayerSerial(client)
accounts = getAccountsBySerial(heSerial)
if (#accounts ~= 0) then
triggerClientEvent("accountFound",client)
else
triggerClientEvent("accountNotFound",client)
end
end

function loginProcces (username , password )
if not getAccount(username) then
triggerClientEvent(client,"clientResponse",client,1 , "INVALID USERNAME")
return
end
if not getAccount(username,password) then
triggerClientEvent(client,"clientResponse",client,2,"INVALID PASSWORD,")
return
end
logIn(client,getAccount(username),password)
triggerClientEvent(client,"clientResponse",client,3)
end

function registerProcces(username, password, email)
if getAccount(username) then
triggerClientEvent(client,"clientResponse",client,4,"THERE IS ANOTHER ACCOUNT WITH THIS NAME TRY SOMETHING NEW ")
return
end
addAccount(username,password)
logIn(client,getAccount(username),password)
setAccountData (getAccount(username),heSerial,password)
setAccountData (getAccount(username),email,username)
triggerClientEvent(client,"clientResponse",client,3)
end
addEventHandler("checkAccounts",getRootElement(),checkingAccounts)
addEventHandler("playerLogins",getRootElement(),loginProcces)
addEventHandler("playerRegisters",getRootElement(),registerProcces)

5 hours ago, Dimos7 said:

Post your full code here

I quoted my full code to my post. by the way thank you for trying to help me

6 hours ago, EstrategiaGTA said:

How would we even try to help you with literally zero lines of your code?

Also, please use a better topic title than "HELP"...

I quoted my full code to my post. by the way thank you for trying to help me  and im also new posting things in forums next time i will put a better name

### [HELP]

Im somewhat new in scripting, i was making a login panel  and the login panel is working and i can login and register but the only problem i have is that when i get join and i'm on the login panel and somebody else joins and is on the panel and mess with it my panel also changes,it acts like the login panel was in the server instead of just the player that joins. to be honest i don't really understand the localPlayer and the root and the getRootElement() and all of that but i have a feeling that that is what is going wrong on my script please help me

×

• #### MTA Network

×
• Create New...