Jump to content

Help with my project (again)


Lander

Recommended Posts

Hi everyone

I've decided for 154434864654546 time to take again my project of MMO Racing in MTA. Before the project was called GTA: Drift City, influenced by the videogame Drift City, now the project has a new name, the name is GTA: San Andreas Racing Syndicate (original, doesn't?), and my new influence is the videogame Test Drive Unlimited.

But, Why taking a project that could be a bad idea???? Simple, I believe in the MTA team. Since the Netzeek's attacks in SA:MP, i've have teaching about MTA in chile, a country where the SA:MP is very popular, even when the SA:MP team has block the access to the master server to all sudamericans.

I'm very noob in LUA, with luck i can make a window gui, administrate my server and use the resources. The only resource that i make was the model and texture change of the cars, following the wiki.

Any help, any collaboration will be aprreciated. Well, let's the project begin.

I have the login gui, i copied the gui from the wiki, and changed some things on the windows, labels, etc..... But, i need the register function for the register gui that i will make later (now in chile is the 11:38 pm), and a rules acceptation windows with two buttons, one for accept (that bring the registation gui) and one for decline (that kick the player), that gui i will make it too.

Now i going to make the gui and them post here.

Thanks for your reading

Lander

Link to comment

OK. i've created the rules acceptation gui, with to buttons: "Accept" and "Don't accept"

From the last gui (login), i need to put a commandHandler for this: If a player need to register, type /register, the login gui disspaear and appear the rules acceptation gui, if the player click on accept, appears the register gui, if don' accept, it's kicked from the server.

This is the rules acceptation gui (the content i will add later, for now, i have this)

function createAcceptationWindow() 
  
        local X = 0.375 
        local Y = 0.375 
        local Width = 0.348 
        local Height = 0.409 
        wdwAccept = guiCreateWindow(X, Y, Width, Height, "Aceptacion de reglas", true) 
         
        X = 0.0431 
        Y = 0.8533 
        Width = 0.2902 
        Height = 0.1247 
        btnAccept = guiCreateButton(X, Y, Width, Height, "Acepto", true, wdwAccept) 
         
        X = 0.0431 
        Y = 0.846 
        Width = 0.2902 
        Height = 0.1247 
        btnNoAccept = guiCreateButton(X, Y, Width, Height, "No Acepto", true, wdwLogin) 
         
        guiSetVisible(wdwLogin, false) 
end 
  

And this the login gui, exactly from the wiki.

function CreateLoginWindow() 
  
        local X = 0.375 
        local Y = 0.375 
        local Width = 0.25 
        local Height = 0.25 
        wdwLogin = guiCreateWindow(X, Y, Width, Height, "Porfavor loguea", true) 
         
        X = 0.0825 
        Y = 0.2 
        Width = 0.25 
        Height = 0.25 
        guiCreateLabel(X, Y, Width, Height, "Usuario", true, wdwLogin) 
        Y = 0.5 
        guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin) 
         
        X = 0.415 
        Y = 0.2 
        Width = 0.5 
        Height = 0.15 
        edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) 
        Y = 0.5 
        edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) 
        guiEditSetMaxLength(edtUser, 50) 
        guiEditSetMaxLength(edtPass, 50) 
         
        X = 0.415 
        Y = 0.7 
        Width = 0.25 
        Height = 0.2 
        btnLogin = guiCreateButton(X, Y, Width, Height, "Logueo", true, wdwLogin) 
         
        guiSetVisible(wdwLogin, false) 
end      
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),  
  
        function () 
                CreateLoginWindow() 
  
                outputChatBox("Bienvenido a San Andreas Racing Syndicate. Porfavor loguea. Si eres nuevo, escribe /registro   ") 
  
                if (wdwLogin ~= nil) then 
                         guiSetVisible(wdwLogin, true) 
                end  
  
                showCursor(true) 
                guiSetInputEnabled(true) 
        end 
  
  
) 
  
function joinHandler(username, password) 
  
        local x,y,z 
        x = 1959.55 
        y = -1714.46 
        z = 10 
        if (client) then 
              spawnPlayer(client, x, y, z) 
              fadeCamera(client, true) 
              outputChatBox("Welcome to My Server", client) 
        end 
end 
  
addEvent("SubmitLogin", true) 
addEventHandler("SubmitLogin", getRootElement(), joinHandler) 
  

Link to comment

First things first, are you developing for DP2.x or for MTA 1.0 (MTA 1.0 has much improved scripting functionality but is unreleased)?. Its also worth mentioning MTA 1.0 will offer proper Joypad/Gamepad support, which will no doubt be essential for any racing servers.

Also, if you still have your SA-MP version of your script, you may be interested in an SA-MP Emulator: https://forum.multitheftauto.com/viewtop ... 15&t=23863. This is only compatible with MTASA 1.0 and will require you download a nightly.

Obviously this is a good solution but we highly reccomend switching to Lua due to speed and sheer scripting capabilities it offers (e.g. just like the GUI you have here, something which is not possible in SA-MP). But yeah, even if you're not strong at Lua we'll be happy to help. You should find there are many perks over using PAWN.

Link to comment
First things first, are you developing for DP2.x or for MTA 1.0 (MTA 1.0 has much improved scripting functionality but is unreleased)?. Its also worth mentioning MTA 1.0 will offer proper Joypad/Gamepad support, which will no doubt be essential for any racing servers.

For now, i have developing the gamemode in 2.3, but will be a good idea to test the nightly builds of 1.0. Thanks for the idea

Also, if you still have your SA-MP version of your script, you may be interested in an SA-MP Emulator: https://forum.multitheftauto.com/viewtop ... 15&t=23863. This is only compatible with MTASA 1.0 and will require you download a nightly.

I never worked with pawn, for me, is very hard than lua.

Obviously this is a good solution but we highly reccomend switching to Lua due to speed and sheer scripting capabilities it offers (e.g. just like the GUI you have here, something which is not possible in SA-MP). But yeah, even if you're not strong at Lua we'll be happy to help. You should find there are many perks over using PAWN.

I have a question, it's possible to combine functions, scripts, etc..., between MTA and SA:MP emulator???? Ex: An arrest script in SA:MP, and a GUI in MTA that show the arrest code in SA:MP emu.

So, let's test the nightly build

Link to comment
First things first, are you developing for DP2.x or for MTA 1.0 (MTA 1.0 has much improved scripting functionality but is unreleased)?. Its also worth mentioning MTA 1.0 will offer proper Joypad/Gamepad support, which will no doubt be essential for any racing servers.

For now, i have developing the gamemode in 2.3, but will be a good idea to test the nightly builds of 1.0. Thanks for the idea

Also, if you still have your SA-MP version of your script, you may be interested in an SA-MP Emulator: https://forum.multitheftauto.com/viewtop ... 15&t=23863. This is only compatible with MTASA 1.0 and will require you download a nightly.

I never worked with pawn, for me, is very hard than lua.

Obviously this is a good solution but we highly reccomend switching to Lua due to speed and sheer scripting capabilities it offers (e.g. just like the GUI you have here, something which is not possible in SA-MP). But yeah, even if you're not strong at Lua we'll be happy to help. You should find there are many perks over using PAWN.

I have a question, it's possible to combine functions, scripts, etc..., between MTA and SA:MP emulator???? Ex: An arrest script in SA:MP, and a GUI in MTA that show the arrest code in SA:MP emu.

So, let's test the nightly build

It is, but its not ideal. Since SA-MP scripts are "gamemodes" and forcefully take control of some aspects you might want to control yourself. For example, SA-MP forcefully provides a spawnscreen which you cannot remove (e.g. you want to add a Login GUI and a License agreement instead). You may be able to modify the emulator to ignore some aspects but that's where it gets complicated.

If i were you i would start from scratch with Lua. MTA provides much better functionality to write your own arrest script - rather than using a crappy "/arrest" command, scripters have the ability to detect bullet shots and melee hits which you can easily use to trigger an arrest.

Link to comment

Well, i've decided to make the gamemode 100% in lua. Because i'm noob in scripting, learning another languaje could be complicted.

Now, i need your help :fadein:

How i can put a command to dissapear the login gui, and appear the License agreement???? Also i need help to script the "don't accept" (no acpeto) button, when is pressed, the player is kicked.

Thanks

Edit:

This is all i got in licence agreement, i wrote the function to change from login to licence agreement

function createAcceptationWindow() 
  
        local X = 0.375 
        local Y = 0.375 
        local Width = 0.348 
        local Height = 0.409 
        wdwAccept = guiCreateWindow(X, Y, Width, Height, "Aceptacion de reglas", true) 
         
        X = 0.0431 
        Y = 0.8533 
        Width = 0.2902 
        Height = 0.1247 
        btnAccept = guiCreateButton(X, Y, Width, Height, "Acepto", true, wdwAccept) 
         
        X = 0.0431 
        Y = 0.846 
        Width = 0.2902 
        Height = 0.1247 
        btnNoAccept = guiCreateButton(X, Y, Width, Height, "No Acepto", true, wdwLogin) 
         
        guiSetVisible(wdwLogin, false) 
end 
  
function hideLoginWindow 
  
                guiSetVisible ( wdwLogin, false )  
                guiSetVisible ( wdwAccept, true ) 
end 
  
addCommandHandler ( registro, hideLoginWindow ) 

Link to comment
Well, i've decided to make the gamemode 100% in lua. Because i'm noob in scripting, learning another languaje could be complicted.

Now, i need your help :fadein:

How i can put a command to dissapear the login gui, and appear the License agreement???? Also i need help to script the "don't accept" (no acpeto) button, when is pressed, the player is kicked.

Thanks

Edit:

This is all i got in licence agreement, i wrote the function to change from login to licence agreement

function createAcceptationWindow() 
  
        local X = 0.375 
        local Y = 0.375 
        local Width = 0.348 
        local Height = 0.409 
        wdwAccept = guiCreateWindow(X, Y, Width, Height, "Aceptacion de reglas", true) 
         
        X = 0.0431 
        Y = 0.8533 
        Width = 0.2902 
        Height = 0.1247 
        btnAccept = guiCreateButton(X, Y, Width, Height, "Acepto", true, wdwAccept) 
         
        X = 0.0431 
        Y = 0.846 
        Width = 0.2902 
        Height = 0.1247 
        btnNoAccept = guiCreateButton(X, Y, Width, Height, "No Acepto", true, wdwLogin) 
         
        guiSetVisible(wdwLogin, false) 
end 
  
function hideLoginWindow 
  
                guiSetVisible ( wdwLogin, false )  
                guiSetVisible ( wdwAccept, true ) 
end 
  
addCommandHandler ( registro, hideLoginWindow ) 

Firstly your registro command handler is wrong, you forgot quote marks, it should be:

addCommandHandler ( "registro", hideLoginWindow ) 

As for the kickPlayer if you dont accept, you will need to use addEvent serverside and triggerServerEvent from the client script under an onClientGUIClick handler. See the examples in onClientGUIClick and triggerServerEvent in the wiki to see what i mean.

Link to comment

As for the kickPlayer if you dont accept, you will need to use addEvent serverside and triggerServerEvent from the client script under an onClientGUIClick handler. See the examples in onClientGUIClick and triggerServerEvent in the wiki to see what i mean.

I saw the examples, but i don't understand, a little help will be apreciated.

Edit: Now i undertand, sorry for disturbed you =/

Link to comment

I got a big problem with the login window

The gui work perfectly, but when press the login button, without write the username and password, the player appears in the map.

What's Wrong?????

Client Side

function CreateLoginWindow() 
  
        local X = 0.375 
        local Y = 0.375 
        local Width = 0.25 
        local Height = 0.25 
        wdwLogin = guiCreateWindow(X, Y, Width, Height, "Porfavor loguea", true) 
         
        X = 0.0825 
        Y = 0.2 
        Width = 0.25 
        Height = 0.25 
        guiCreateLabel(X, Y, Width, Height, "Usuario", true, wdwLogin) 
        Y = 0.5 
        guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin) 
         
        X = 0.415 
        Y = 0.2 
        Width = 0.5 
        Height = 0.15 
        edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) 
        Y = 0.5 
        edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) 
        guiEditSetMaxLength(edtUser, 50) 
        guiEditSetMaxLength(edtPass, 50) 
         
        X = 0.415 
        Y = 0.7 
        Width = 0.25 
        Height = 0.2 
        btnLogin = guiCreateButton(X, Y, Width, Height, "Logueo", true, wdwLogin) 
         
        guiSetVisible(wdwLogin, false) 
end      
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),  
  
        function () 
                CreateLoginWindow() 
                addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) 
  
                outputChatBox("Bienvenido a San Andreas Racing Syndicate. Porfavor loguea. Si eres nuevo, escribe /registro   ") 
  
                if (wdwLogin ~= nil) then 
                         guiSetVisible(wdwLogin, true) 
                end  
  
                showCursor(true) 
                guiSetInputEnabled(false) 
        end 
  
  
) 
  
function clientSubmitLogin(button) 
  
        if button == "left" then 
                 
                triggerServerEvent("SubmitLogin", getRootElement(), guiGetText(edtUser), guiGetText(edtPass)) 
                guiSetInputEnabled(false) 
                guiSetVisible(wdwLogin, false) 
                showCursor(false) 
        end 
end 
  

Server Side

function joinHandler(username, password) 
  
        local x,y,z 
        x = 1959.55 
        y = -1714.46 
        z = 10 
        if (client) then 
              spawnPlayer(client, x, y, z) 
              fadeCamera(client, true) 
              outputChatBox("Bienvenido de vuelta", client) 
        end 
end 
  
addEvent("SubmitLogin", true) 
addEventHandler("SubmitLogin", getRootElement(), joinHandler) 
  

As you can see, the script is taken from the wiki, with small modifications

Link to comment

like this?????

function clientSubmitLogin(button) 
  
        if button == "left" then 
                 
                if guiGetText(wdwLogin) ~= "" then 
                triggerServerEvent("SubmitLogin", getRootElement(), guiGetText(edtUser), guiGetText(edtPass)) 
                guiSetInputEnabled(false) 
                guiSetVisible(wdwLogin, false) 
                showCursor(false) 
        end 
end 
  

Link to comment

Something similar. You must pay attention to end when using if, elseif and else statements. Also, what wdwLogin is? Assuming to your code it's a Window, so you don't want to get the text of the window title bar but the edit (text box) so you must check if edtUser and edtPass are not empty strings.

if ( guiGetText( edtUser ) ~= "" ) and ( guiGetText( edtPass ) ~= "" ) then 
-- rest of the code 
end 

I recommend you type end just after then (the next line). That way you will always have the statements "closed".

Link to comment
Something similar. You must pay attention to end when using if, elseif and else statements. Also, what wdwLogin is? Assuming to your code it's a Window, so you don't want to get the text of the window title bar but the edit (text box) so you must check if edtUser and edtPass are not empty strings.
if ( guiGetText( edtUser ) ~= "" ) and ( guiGetText( edtPass ) ~= "" ) then 
-- rest of the code 
end 

I recommend you type end just after then (the next line). That way you will always have the statements "closed".

The code was taken from the wiki. wdwLogin is the login windows for my gamemode, also taken from the wiki.

Now, I put

if ( guiGetText( edtUser ) ~= "" ) and ( guiGetText( edtPass ) ~= "" ) then 
-- rest of the code 
end 

And works, but when someone write a random username and password, it's enter to the game too.

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...