John Smith Posted March 28, 2014 Posted March 28, 2014 (edited) Solved. Edited March 29, 2014 by Guest If you find my post useful or if it helped you, please like my post Ingame name: ZoeN
justn Posted March 28, 2014 Posted March 28, 2014 (edited) This should be changed to addEventHandler("onPlayerJoin",source,spawnSumoPlayer) -- Line 9 addEventHandler("onPlayerSpawn",source,spawnSumoPlayer) -- Line 35 this addEventHandler("onPlayerJoin",getRootElement(),spawnSumoPlayer) -- Line 9 addEventHandler("onPlayerSpawn",getRootElement(),spawnSumoPlayer) -- Line 35 Edited March 28, 2014 by Guest Datastore - Store data to a database quickly. (Useful for saving scripted tables)
Castillo Posted March 28, 2014 Posted March 28, 2014 addEventHandler("onPlayerJoin",source,spawnSumoPlayer) Change 'source' to 'root' and remove 'source' from function name, it's already defined by itself. Also, this makes no sense: spawnPoints = { [1]=true, [2]=true, } spawnPlayer(source,spawnPoints[math.random (1,2)]) You are giving spawnPlayer a boolean ( true ). San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
justn Posted March 28, 2014 Posted March 28, 2014 As solidsnake said, that doesn't make sense, try my code below spawnPoints = { -- { x, y, z } } function spawnSumoPlayer() for i,v in ipairs (spawnPoints) do spawnPlayer(source,v[1], v[2], v[3] ) end end addEventHandler("onPlayerJoin",getRootElement(),spawnSumoPlayer) Datastore - Store data to a database quickly. (Useful for saving scripted tables)
Castillo Posted March 28, 2014 Posted March 28, 2014 That code will spawn the player as many times as spawnpoints the table has. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
John Smith Posted March 28, 2014 Author Posted March 28, 2014 spawnPoints = { [1] = 2702.2, -3018.6, 99.9 [2] = 2696.7, -3015.9, 99.9 } something seems to be wrong in here,and as im noob in lua idk what. i dont know which code to use to make this thing work and its confusing me If you find my post useful or if it helped you, please like my post Ingame name: ZoeN
manawydan Posted March 28, 2014 Posted March 28, 2014 math.random ? "Querer não é poder, mas tentar é avançar"!
Castillo Posted March 28, 2014 Posted March 28, 2014 spawnPoints = { [1] = { 2702.2, -3018.6, 99.9 }, [2] = { 2696.7, -3015.9, 99.9 } } San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
John Smith Posted March 28, 2014 Author Posted March 28, 2014 thanks again solidsnake14,but i got another problem here is my wrong part of code..again spawnPoints = { [1] = { 2702.2, -3018.6, 99.9 }, [2] = { 2696.7, -3015.9, 99.9 } } function spawnSumoPlayer(source) for i,v in ipairs (spawnPoints) do spawnPlayer(source,spawnPoints[math.random v[1], v[2] ) end end addEventHandler("onPlayerJoin",getRootElement(),spawnSumoPlayer) i've never used math.random before so i didnt know exactly where to place it it gives this error [22:36:28] SCRIPT ERROR: [gamemodes]\[sumo]\sumo\load_map\spawn_s.lua:19: ']' expected near 'v'[22:36:28] ERROR: Loading script failed: [gamemodes]\[sumo]\sumo\load_map\spawn_s.lua:19: ']' expect ed near 'v' If you find my post useful or if it helped you, please like my post Ingame name: ZoeN
Castillo Posted March 28, 2014 Posted March 28, 2014 spawnPoints = { [ 1 ] = { 2702.2, -3018.6, 99.9 }, [ 2 ] = { 2696.7, -3015.9, 99.9 } } function spawnSumoPlayer ( ) spawnPlayer ( source, unpack ( spawnPoints [ math.random ( #spawnPoints ) ] ) ) end addEventHandler ( "onPlayerJoin", getRootElement(), spawnSumoPlayer ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
John Smith Posted March 28, 2014 Author Posted March 28, 2014 i have no idea what this means. [22:41:24] ERROR: [gamemodes]\[sumo]\sumo\load_map\spawn_s.lua:19: C stack overflow If you find my post useful or if it helped you, please like my post Ingame name: ZoeN
Castillo Posted March 28, 2014 Posted March 28, 2014 What line is that? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
John Smith Posted March 28, 2014 Author Posted March 28, 2014 spawnPlayer ( source, unpack ( spawnPoints [ math.random ( #spawnPoints ) ] ) ) If you find my post useful or if it helped you, please like my post Ingame name: ZoeN
Castillo Posted March 28, 2014 Posted March 28, 2014 Post the entire code, I think that you have a function also called "spawnPlayer". San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
John Smith Posted March 28, 2014 Author Posted March 28, 2014 (edited) ----- Edited March 29, 2014 by Guest If you find my post useful or if it helped you, please like my post Ingame name: ZoeN
Castillo Posted March 28, 2014 Posted March 28, 2014 addEventHandler("onPlayerSpawn",root,spawnSumoPlayer) That line is causing the stack overflow, once you spawn, it's spawning you again in a non stop loop. Simply remove it. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
John Smith Posted March 28, 2014 Author Posted March 28, 2014 Now the error is fixed but, when i join the game it started my map but screen is black. If you find my post useful or if it helped you, please like my post Ingame name: ZoeN
Castillo Posted March 28, 2014 Posted March 28, 2014 function spawnSumoPlayer ( ) spawnPlayer ( source, unpack ( spawnPoints [ math.random ( #spawnPoints ) ] ) ) fadeCamera ( source, true ) setCameraTarget ( source, source ) end addEventHandler ( "onPlayerJoin", getRootElement(), spawnSumoPlayer ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
John Smith Posted March 28, 2014 Author Posted March 28, 2014 still black screen,console spammed with this: [23:49:40] WARNING: [gamemodes]\[sumo]\sumo\load_map\spawn_s.lua:20: Bad argument @ 'fadeCamera' If you find my post useful or if it helped you, please like my post Ingame name: ZoeN
Castillo Posted March 28, 2014 Posted March 28, 2014 My bad, I forgot something, copy it again. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
John Smith Posted March 28, 2014 Author Posted March 28, 2014 okay thanks, now it spawns me as a ped but why doesnt it spawn me into a random car? car part of code function changeVehicle (state) if state == "Running" then setTimer (function () local players = getAlivePlayers () for playerKey, playerValue in ipairs(players) do setElementModel (getPedOccupiedVehicle(playerValue), vehicles[math.random(#vehicles)]) end end, 1000, 1) end end addEvent("onRaceStateChanging", true) addEventHandler ("onRaceStateChanging", getRootElement (), changeVehicle) function changePlayersVeh () setElementModel (getPedOccupiedVehicle(source), vehicles[math.random(#vehicles)]) end addEvent("changeVeh", true) addEventHandler("changeVeh", getRootElement(), changePlayersVeh) addEventHandler("onPlayerSpawn",root,spawnSumoPlayer) probably an epic fail in there as i was just copying examples from wiki/other sites but it just needs to spawn me in random vehicle when player spawns If you find my post useful or if it helped you, please like my post Ingame name: ZoeN
Castillo Posted March 28, 2014 Posted March 28, 2014 You are using race events, why do you even need to spawn the player? race does it all by itself. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
John Smith Posted March 28, 2014 Author Posted March 28, 2014 as im a noob,i've just copied few lines of code from some examples on wiki probably and didnt change race events at all cause i didn't know what to do with them,but i'm not using race gamemode at all, so i don't know how to spawn them inside a car btw sry if im asking for too much i just wanna learn this since i cant learn on other way than asking in here If you find my post useful or if it helped you, please like my post Ingame name: ZoeN
Castillo Posted March 28, 2014 Posted March 28, 2014 spawnPoints = { [ 1 ] = { 2702.2, -3018.6, 99.9 }, [ 2 ] = { 2696.7, -3015.9, 99.9 } } vehicles = {602,545,496,517,401,410,518,600,527,436,589,580,419,439,533,549,526,491,474,445,604,507,585,587,466,492,546,551,516,467,426,547,405,409,550,566,540,421,529,581,509,481,462,521,463,510,522,461,448,468,586,485,552,431,438,437,574,420,525,408,416,433,427,490,528,407,544,523,470,598,596,597,599,601,428,499,609,498,524,532,578,486,406,573,455,588,403,514,423,414,443,515,531,456,459,422,482,605,530,418,572,582,413,440,543,583,478,554,536,575,534,567,535,576,412,402,542,603,475,568,424,504,457,483,508,571,500,444,556,557,471,495,539,429,541,415,480,562,565,323,492,502,503,411,559,561,560,506,451,558,555,477,579,400,404,489,505,479,442,458} function spawnSumoPlayer ( ) local model = vehicles [ math.random ( #vehicles ) ] local vehicle = createVehicle ( model, unpack ( spawnPoints [ math.random ( #spawnPoints ) ] ) ) if spawnPlayer ( source, unpack ( spawnPoints [ math.random ( #spawnPoints ) ] ) ) then fadeCamera ( source, true ) setCameraTarget ( source, source ) warpPedIntoVehicle ( source, vehicle ) end end addEventHandler ( "onPlayerJoin", getRootElement(), spawnSumoPlayer ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
John Smith Posted March 28, 2014 Author Posted March 28, 2014 Thank you very very much! just 1 more thing if you got time, i've made a code to respawn player when he dies in his car --1 part of big server side script(the one you saw before) function respawnSumoPlayer ( ) removeEventHandler("onPlayerJoin",true) spawnPlayer ( source, unpack ( spawnPoints [ math.random ( #spawnPoints ) ] ) ) fadeCamera ( source, true ) setCameraTarget ( source, source ) end addEventHandler ( "onPlayerWasted", getRootElement(), spawnSumoPlayer ) and new made lua file function onSumoPlayerVehicleExit(player) if isPedInVehicle(player) then killPed(player) else outputDebugString("a player pressed enter/f key without being in a vehicle.") end end bindKey(player, "enter", "down", onSumoPlayerVehicleExit) bindKey(player, "f", "down", onSumoPlayerVehicleExit) addEventHandler("onVehicleStartExit",root,onSumoPlayerVehicleExit) idk how tho it spawns a ped into vehicle but how could i set a timer on this? so that after death it respawns player after 5 seconds? If you find my post useful or if it helped you, please like my post Ingame name: ZoeN
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