-
Posts
656 -
Joined
-
Last visited
-
Days Won
2
Everything posted by John Smith
-
It works Ali_Digitali,thanks, but how could i make this script with fileCreate and fileWrite?i mean so that it stays permanent
-
i dont know which functions i had to use so i had to guess, i didnt use sql because i dont know a single thing about it,and with fileWrite ofc i failed. local playerAccount = getPlayerAccount(source) local playerSerial = getPlayerSerial(source) local playerNick = getPlayerName(source) local fileSerial = fileCreate("test.txt") function savePlayerSerial(_,playerAccount) if (playerAccount) and isGuestAccount(source) then if fileSerial then fileWrite(fileSerial, playerNick, " - ", playerSerial ) fileClose(fileSerial) end end end addEventHandler("onPlayerJoin",root,savePlayerSerial) i just wanted to do a test to see will this even work before writing other part of code,but ofc i made probably an epic fail. please help me i dont understand this
-
tried this function noNameYet(_,playerAccount) local playerAccount = getPlayerAccount(source) local playerSerial = getPlayerSerial(source) local playerNick = getPlayerName(source) if (playerAccount) and isGuestAccount(source) then if (serial) then setAccountData(source,playerAccount,"player.guest",playerSerial) else outputChatBox("could not load" ..playerNick.. "'s serial",getRootElement(),255,0,0) end end end addEventHandler("onPlayerJoin",root,noNameYet) function otherFunction(_,playerAccount) local getGuestAccount = getAccountData(source) if (getGuestAccount [source,playerAccount,"player.guest",playerSerial] ) then outputChatBox(playerNick.. "has joined the game [New Player]",getRootElement(),0,190,0) setAccountData(source,playerAccount,"player.regular",playerSerial) end end addEventHandler("onPlayerJoin",root,otherFunction) function otherState(_,playerAccount) if (getGuestAccount [source,playerAccount,"player.regular",playerSerial]) then outputChatBox(playerNick.. "has joined the game [Regular Player]",getRootElement(),0,190,0) end end addEventHandler("onPlayerJoin",root,otherState)
-
You're welcome.
-
go to your mta directory
-
What about guest users?it will only say new player for newly registered players,and not for new guests
-
nope,still new player
-
@Ali_Digitali, I'm always considered as New Player with your script
-
okay so,now my code is like this. function setPlayerState() local elementdata = getElementData(source,"data.joindataold") if (elementdata) then return else setElementData(source, "data.joindatanew", "player.newplayer") end end addEventHandler("onPlayerJoin",root,setPlayerState) function checkPlayerState() local check = getPlayerSerial(source) local playername = getPlayerName(source) if getElementData(source, "data.joindataold") then outputChatBox(playername.. "has joined the game [Regular Player]",0,190,90) elseif getElementData(source, "data.joindatanew") then outputChatBox(playername.. "has joined the game [New Player]",source,0,190,90) end end addEventHandler("onPlayerJoin",root,checkPlayerState) function savePlayerData() setElementData(source,"player.serial",check) end addEventHandler("onPlayerJoin",root,savePlayerData) it always considers me as new player,and the funny thing is that 1st outputChatBox is same as 2nd one,only text is different but it gave an error that it got '0' as 2nd argument. i just dont know what the fuck is this i had to put 'source' in that 2nd outputChatBox and now nobody else can see when new player joins the game as it outputs the message only to the source(new joined player) please help me,this is confusing me too much edit: in order to fix this new player and regular player thing i've added few lines of code function makeRegularPlayer() if getElementData(source,"data.joindatanew") then setTimer(function() setElementData(source,"data.joindataold",check) -- line 31 end,5000,1) end end addEventHandler("onPlayerJoin",root,makeRegularPlayer) so now i got a problem with this error,and outputchatbox(2nd one)
-
function setPlayerState(thePlayer) local elementdata = getElementData(thePlayer,"data.joindataold") if (elementdata) then return else setElementData(thePlayer, "data.joindatanew", "player.newplayer") end end addEventHandler("onPlayerJoin",root,setPlayerState) function checkPlayerState(thePlayer) local check = getPlayerSerial(player) local playername = getPlayerName(thePlayer) if getElementData(thePlayer, "data.joindataold") then outputChatBox(playername.. "has joined the game [Regular Player]",0,190,90) elseif getElementData(thePlayer, "data.joindatanew") then outputChatBox(playername.. "has joined the game [New Player]",0,190,90) end end addEventHandler("onPlayerJoin",root,checkPlayerState) function savePlayerData(thePlayer) setElementData(thePlayer,"player.serial",check) end addEventHandler("onPlayerJoin",root,savePlayerData)
-
I've tried(my first try) to setElementData for new players and regular players(who at least joined once) i don't know how to do this exactly. how would i check if serial of player has got element data ,etc.. its confusing me. i have 2 kind of codes(same script file), both return errors. 1st function setPlayerState(thePlayer) local elementdata = getElementData(thePlayer) if (elementdata == "data.joindataold") then return else setElementData(thePlayer, "data.joindatanew") end end addEventHandler("onPlayerJoin",root,setPlayerState) function checkPlayerState(thePlayer) local check = getPlayerSerial(player) local playername = getPlayerName(thePlayer) if getElementData(thePlayer, "data.joindataold") then outputChatBox(playername.. "has joined the game [Regular Player]",0,190,90) elseif getElementData(thePlayer, "data.joindatanew") then outputChatBox(playername.. "has joined the game [New Player]",0,190,90) end end addEventHandler("onPlayerJoin",root,checkPlayerState) function savePlayerData(thePlayer) setElementData(thePlayer,check) end addEventHandler("onPlayerJoin",root,savePlayerData) errors: 2nd code(same script file) function setPlayerState() local elementdata = getElementData(source) if (elementdata == "data.joindataold") then return else setElementData(source, "data.joindatanew") end end addEventHandler("onPlayerJoin",root,setPlayerState) function checkPlayerState() local check = getPlayerSerial(source) local playername = getPlayerName(source) if getElementData(source, "data.joindataold") then outputChatBox(playername.. "has joined the game [Regular Player]",0,190,90) elseif getElementData(source, "data.joindatanew") then outputChatBox(playername.. "has joined the game [New Player]",0,190,90) end end addEventHandler("onPlayerJoin",root,checkPlayerState) function savePlayerData() setElementData(source,check) end addEventHandler("onPlayerJoin",root,savePlayerData) errors: please help me, i dont understand how to fix/make this as im new to this btw why dont tags work?
-
Thank you!
-
i've tried this too addEventHandler("onPlayerWasted", root, function() setTimer( function(source) local vehicle = createVehicle ( model, unpack ( spawnPoints [ math.random ( #spawnPoints ) ] ) ) spawnPlayer ( source, unpack ( spawnPoints [ math.random ( #spawnPoints ) ] ) ) ) setCameraTarget ( source, source ) warpPedIntoVehicle ( source, vehicle ) end, 5000, 1, source ) end) it respawns me but how can i make it respawn me into random vehicle?
-
function respawnSumoPlayer() addEventHandler("onPlayerWasted",getRootElement(), setTimer(function() spawnPlayer ( source, unpack ( spawnPoints [ math.random ( #spawnPoints ) ] ) ) setCameraTarget ( source, source ) end, 5000, 1 )) end im not respawning and my camera is going higher and higher because im dead
-
I've removed that removeEventHandler but i didn't understand clearly what u meant with 2) is this good? function onSumoPlayerVehicleExit(player) if isPedInVehicle(player) then killPed(player) else outputDebugString("a player pressed enter/f key without being in a vehicle.") end end addEventHandler("onVehicleStartExit",root,onSumoPlayerVehicleExit) function bindKill(player) bindKey(player, "enter", "down", onSumoPlayerVehicleExit) bindKey(player, "f", "down", onSumoPlayerVehicleExit) end addEventHandler("onPlayerJoin",root,bindKill) btw idk how to set a timer when player should respawn(5 sec)
-
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?
-
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
-
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
-
still black screen,console spammed with this:
-
Now the error is fixed but, when i join the game it started my map but screen is black.
-
-----
-
spawnPlayer ( source, unpack ( spawnPoints [ math.random ( #spawnPoints ) ] ) )
-
i have no idea what this means.
-
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
-
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