Stalker157 Posted August 27, 2022 Share Posted August 27, 2022 Hello, I have some questions about scripting MTA. First, what is the difference between Server functions and Client functions? And when to use them? Currently I'm using Server functions only. Second, I'm trying to make ammunation script like this: But how to change the camera position to view every weapon by pressing left and right arrow? And how to make the player able to buy the selected weapon? Also how to cancel the player from buying weapons, for example press 'Enter'. Link to comment
AngelAlpha Posted August 27, 2022 Share Posted August 27, 2022 2 hours ago, Stalker157 said: Hello, I have some questions about scripting MTA. First, what is the difference between Server functions and Client functions? And when to use them? Currently I'm using Server functions only. Second, I'm trying to make ammunation script like this: But how to change the camera position to view every weapon by pressing left and right arrow? And how to make the player able to buy the selected weapon? Also how to cancel the player from buying weapons, for example press 'Enter'. 1. But how to change the camera position to view every weapon by pressing left and right arrow? setCameraMatrix + render + interpolateBetween 2. And how to make the player able to buy the selected weapon? When click left or right, save cur num weapon local curWeapon = 1 function onKey(key) if key == "arrow_left" then curWeapon = curWeapon - 1 moveCamera () elseif key == "arrow_right" then curWeapon = curWeapon + 1 moveCamera () elseif key == "enter" then buyWeapon () end end addEventHandler ("onClientKey", root, onKey) function moveCamera () --[[ setCameraMatrix() ]] end function buyWeapon () --[[ curWeapon ]] end 3. Also how to cancel the player from buying weapons, for example press 'Enter'. onClientKey + check, if window error showing then when press 'Enter' - window close, else buyWeapon Link to comment
Stalker157 Posted August 27, 2022 Author Share Posted August 27, 2022 Quote setCameraMatrix + render + interpolateBetween I can't figure out how to use them.. Link to comment
Moderators IIYAMA Posted August 27, 2022 Moderators Share Posted August 27, 2022 6 hours ago, Stalker157 said: First, what is the difference between Server functions and Client functions? And when to use them? Currently I'm using Server functions only. First of all, it important to understand there is serverside and there is clientside. Serverside is running on the server application, or just call it the server. This is where all players connect to in order to player the game together. MTA San Andreas 1.5\server\MTA Server.exe Here are server functions available. Clientside in running on each game application. It is literally the MTA game. MTA San Andreas 1.5\Multi Theft Auto.exe Keep in mind that there can multiple clientsides. For each connected player there is a clientside. The data between those clientsides is not shared. Here are client functions available. The reason why some function are not available on the other side is many because of security restrictions. You do not want to grant all players the rights to be able to ban each other, only the server should be able to ban a player. And some functions are just not so useful at the other side, like drawing an image just 1 frame on your screen. Imagine having server doing that every frame, your internet will just die. Link to comment
Stalker157 Posted August 28, 2022 Author Share Posted August 28, 2022 Now I've managed to bind the key "F" to the marker I have made in ammu-nation local Marker1 = createMarker(295.70001, -38.2, 1000.6, "cylinder", 1.5, 255, 255, 0, 0) setElementInterior(Marker1, 1) function MarkerHit(player) if getElementType(player) == "player" and source == Marker1 then bindKey(player, "f", "down", camera) outputChatBox("Press F to buy weapons", player) end end addEventHandler("onMarkerHit", getRootElement(), MarkerHit) function MarkerLeave(player) if getElementType(player) == "player" and source == Marker1 then unbindKey(player, "f", "down", camera) end end addEventHandler("onMarkerLeave", getRootElement(), MarkerLeave) function camera(player, key, keyState) setCameraMatrix(player, 293.10001, -39.8, 1002.8, 293.10001 , -41.8, 1002.8) end Now I want to know how to make the camera move from an object to another one using "Left" and "Right" arrow. The places I want the camera goes to setCameraMatrix(293.10001, -39.8, 1002.8, 293.10001, -41.8, 1002.8) setCameraMatrix(293, -39.8, 1002.4, 293, -41.8, 1002.4) setCameraMatrix(293, -39.8, 1002, 293, -41.8, 1002) setCameraMatrix(293.79999, -39.83, 1002.7, 293.79999, -41.83, 1002.7) setCameraMatrix(293.79999, -39.8, 1002.3, 293.79999, -41.8, 1002.3) setCameraMatrix(293.79999, -39.83, 1001.95, 293.79999, -41.83, 1001.95) setCameraMatrix(295, -39.8, 1002.05, 295, -41.8, 1002.05) setCameraMatrix(294.89999, -39.8, 1002.33, 294.89999, -41.8, 1002.33) setCameraMatrix(294.89999, -39.8, 1002.81, 294.89999, -41.8, 1002.81) setCameraMatrix(296.29999, -39.8, 1002.53, 296.29999, -41.8, 1002.53) setCameraMatrix(296.29999, -39.8, 1002, 296.29999, -41.8, 1002) setCameraMatrix(297.89999, -39.8, 1002.6, 297.89999, -41.8, 1002.6) setCameraMatrix(297.89999, -39.8, 1002.1, 297.89999, -41.8, 1002.1) setCameraMatrix(299.39999, -39.6, 1002.4, 299.39999, -41.6, 1002.4) setCameraMatrix(298.29999, -36.4, 1001.8, 298.29999, -38.4, 1001.8) setCameraMatrix(297.39999, -37, 1001.84, 297.39999, -39, 1001.84) setCameraMatrix(296.70001, -37.04, 1001.6, 296.70001, -39.04, 1001.6) setCameraMatrix(296.39999, -37.04, 1001.577, 296.39999, -39.04, 1001.577) setCameraMatrix(293.20001, -37, 1001.6, 293.20001, -39, 1001.6) setCameraMatrix(293.60001, -37, 1001.7, 293.60001, -39, 1001.7) setCameraMatrix(294.20001, -37, 1001.635, 294.20001, -39, 1001.635) And can anyone explain these? Quote 1. But how to change the camera position to view every weapon by pressing left and right arrow? setCameraMatrix + render + interpolateBetween 2. And how to make the player able to buy the selected weapon? When click left or right, save cur num weapon Link to comment
Stalker157 Posted September 1, 2022 Author Share Posted September 1, 2022 All I want to know is how to change between my setCameraMatrix with left or right keys and if possible with up and down. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now