Jump to content

Citizen

Moderators
  • Posts

    1,803
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by Citizen

  1. Of course, I don't know where do you want that the player can click ( is this sentence correct ? ) So where you want to click ? Because if you made this, it works perfectly: if ( screenx >= 0 ) and ( screenx <= 1 ) and ( screeny >= 0 ) and ( screeny <= 1 ) then
  2. Try this ( replace SoundWave by your name In-Game ): Server: --REGISTER THE PLAYER function tryToRegsiterPlayer(player, username, pass) if not getAccount(username, pass) then theAccount = addAccount(username, pass) if (theAccount) then logIn(player, theAccount, pass) outputChatBox("* You successfully registered account '" ..username.. "' for player '" ..getPlayerName(player).. "' with password '" ..pass.."'!", player, 0, 255, 0, false) local you = getPlayerFromName( "SoundWave" ) outputChatBox(" The player "..getPlayerName(player).." have been registered with the login "..username, you ) triggerClientEvent("onRegisterPlayWelcomeSound", player) triggerClientEvent("onPlayerFirstTimeSeen", player) triggerClientEvent("onPlayerDoneLogin", player) setTimer(triggerClientEvent, 3000, 1, "onPlayerPlayUEFASound", player, false) else reason = "The Account already exists!" triggerClientEvent("onServerWrongLoginRebuildLogin", root, player, reason) end else reason = "The Account already exists!" triggerClientEvent("onServerWrongLoginRebuildLogin", root, player, reason) end end addEvent("onClientSendRegisterDataToServer", true) addEventHandler("onClientSendRegisterDataToServer", getRootElement(), tryToRegsiterPlayer)
  3. This script can't work except if you are very lucky ^^ I explain; for exemple here: if ( screenx == 0.3077 ) and ( screeny == 0.5103 ) then it work's if the player click at 0.3077 ( x ) and 0.5103 ( y ) on the screen => It's almost IMPOSSIBLE You have to specify a range of x and for y; for exemple like this: if ( screenx >= 0.3077 ) and ( screenx <= 0.3477 ) and ( screeny >= 0.5103 ) and ( screeny <= 0.5503 ) then Here I made a little square of 0.4 ( Width ) and 0.4 ( Height ), so your players can click easily on this.
  4. Citizen

    Resources

    I'm not sure but I think you can't sorry ( Maybe I'm wrong )
  5. @SolidSnake: I think that he want to return the playerName whithout the hexa color so it's: return playerName2 But I'm sure that you just forgot it ^^ @AcitanoX: You can't make that: local playerName = something local playerName = somethingElse But you can like this: local playerName = something playerName = somethingElse ( I delete the second "local" => but the variable stay to a local variable )
  6. setElementData( yourPlayer, "Admin", 1 ) -- then if getElementData( yourPlayer, "Admin" ) ~= false then -- if is an admin then -- do something end --------- Expulse him from the AdminTeam: removeElementData( yourPlayer, "Admin" ) -- destroy the elementData -- or setElementData( yourPlayer, "Admin", false ) -- Keep the elementData in the memory but know that player isn't an admin
  7. How and when that player "becomes a member of your team" ? We need the register code if you want some help
  8. Ok ( gg for your 400nd posts )
  9. You means that my code can't to fix your problem of spamming ? My script solves this problem ! But if you found another way, good job
  10. You can use the player's ID only if you set a unique ID for the player when he joins the server ( or at the spawn or at the login; like you want ), then: function SlapPlayer(theplayer, command, otherplayername, ...) otherplayer = getPlayerFromName( tostring(otherplayername) ) or getElementByID( tostring(otherplayername) ) -- if you specify an ID, getPlayerFromName return false and getElementByID return the player if the player's ID is correct so ... -- otherplayer = false or thePlayerElement -- so otherplayer = thePlayerElement local x, y, z = getElementPosition(otherplayer) local pname = getPlayerName(theplayer) local gname = getPlayerName(otherplayer) z = z+5 succes = setElementPosition(otherplayer, x, y, z) if(succes) then outputChatBox(gname.." Was Slapped By Admin "..pname.." Reason : "..table.concat ({...}, ' '), getRootElement(), 255, 0, 0, true) else outputChatBox("Failed", theplayer) end end addCommandHandler("sslap", SlapPlayer) ( I made another post because the forum said that there are too few characters in my post --' )
  11. Yes you can use that function: local distance = getDistanceBetweenPoints3D( playerX, playerY, playerZ, gateX, gateY, gateZ ) if distance <= 15 then openGate() end But it's more difficult and need more CPU( due to the setTimer ) than this: shapeGate = createColTube( gateX, gateY, gateZ, 15, 10 ) function openGate() -- open the gate end addEventHandler("onColShapeHIT", shapeGate, openGate )
  12. Yeah where is it ? ( I think in onPlayerWasted right ? ) Why your script spaming you ? ( see the comments ): function LevelSystemShowUpLevel() local EXP5 = getElementData(source,"Experience") -- for exemple EXP5 = 25 ... if tonumber( EXP5 ) == 25 then -- ...so if 25 == 25 then ... setElementData ( source, "Level", 2) -- here the onElementDataChange is triggered again but the Experience is always 25 so it do it again etc ... ... To fix this problem, you can add another condition like the current level: function LevelSystemShowUpLevel() local lvl = getElementData(source,"Level") local EXP5 = getElementData(source,"Experience") if EXP5 == 25 and tonumber( lvl ) ~= 2 then setElementData ( source, "Level", 2) triggerClientEvent(source,"LevelSystemShowPlayerLevel",source) outputChatBox ( source, "New Level 2!", source,0,255,0) setElementData ( source, "NextLevel", 75) end if EXP5 == 75 and tonumber( lvl ) ~= 3 then setElementData ( source, "Level", 3) triggerClientEvent(source,"LevelSystemShowPlayerLevel",source) outputChatBox ( source, "New Level 3!", 0,255,0) setElementData ( source, "NextLevel", 150) end end addEventHandler("onElementDataChange",getRootElement(),LevelSystemShowUpLevel)
  13. if you want to check if min == 30, you have to call your function every 1 min ( = 60 sec = 60000ms ) with a setTimer: function yourFunction() local hour, mins = getTime() if( tonumber( mins ) == 30 ) then outputChatBox("It's now "..hour..":30 !") end end setTimer( yourFunction, 60000, 0 )
  14. Haha thanks a lot ^^ See you soon
  15. In the command, you specify the player's name so...: function GetPlayerHere(theplayer, command, otherplayerName ) local x, y, z = getElementPosition(theplayer) otherplayer = getPlayerFromName( otherplayerName ) succes = setElementPosition(otherplayer, x, y, z) if(succes) then outputChatBox("succes", theplayer) else outputChatBox("fail", theplayer) end end addCommandHandler("gethere", GetPlayerHere) function GoToPlayer(theplayer, command, otherplayer) otherplayer = getPlayerFromName( otherplayerName ) local x, y, z = getElementPosition( otherplayer ) succes = setElementPosition(theplayer, x, y, z) if(succes) then outputChatBox("succes", theplayer) else outputChatBox("Fail", theplayer) end end addCommandHandler("goto", GoToPlayer)
  16. Hi The-Kup9, You can't give weapons for player in a .map file, but only made a pickup on the ground. You should make it with the mapEditor, you places the spawns and the weapons, in your map then save it ! The map file is generated. If you don't know, the MapEditor is on the welcome screen of the MTA.
  17. --------------------------------------------------------------------------- 1st Script: ------------------------------------------------------------------- Try to replace by this: triggerClientEvent(thePlayer, "onSetText", getRaceW, getRaceL, getRaceAtp) And this (tostring instead of tonumber ): addEvent("onSetText", true) function setText(theW, theL, theA) guiSetText(GUIEditor_Label[1], tostring(theA)) guiSetText(GUIEditor_Label[2], tostring(theW)) guiSetText(GUIEditor_Label[3], tostring(theL)) guiSetText(GUIEditor_Label[6], tostring(getElementData(getLocalPlayer(), "Points"))) guiSetText(GUIEditor_Label[7], tostring(getElementData(getLocalPlayer(), "Money"))) guiSetText(GUIEditor_Label[8], tostring(getElementData(getLocalPlayer(), "Skill Points"))) end addEventHandler("onSetText", getRootElement(), setText) --------------------------------------------------------------------------- 2nd Script: ------------------------------------------------------------------- Here is the tonumber too ! And the true at the end of guiGridListSetItemText ( Not really important ^^ ): local skins = {0,7,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,30,31,32,33,34,35,36,37,38,39,40,41,43,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,62,63,64,65,66,67,68,69,70} for v,skin in ipairs(skins) do row = guiGridListAddRow(GUIEditor_Grid[1]) guiGridListSetItemText(GUIEditor_Grid[1], row, clm, tostring(skin), false, true) end clm is your column right ? ( I mean this ( not local ): clm = guiGridListAddColumn ( ... ) )
  18. Server-Side: addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() for i,player in ipairs(getElementsByType("player")) do spawn(player) -- Why spawn all players ? Because they have not chosen their team yet --' end end ) function spawn(player) repeat until spawnPlayer ( player, -2252.1818847656, 2278.2119140625, 1073.4588623047 ) fadeCamera(player, true) setCameraTarget(player, player) end addEventHandler("onPlayerJoin", root, function() spawn(source) end ) teamhunters = createTeam ("Hunters", 0, 255, 0 ) teamreapers = createTeam ("Reapers", 200, 0, 100 ) teamstalkers = createTeam ( "Stalkers", 200, 0, 100 ) function player_Wasted() if team == teamhunters then spawnPlayer(source, the coords of hunters base) elseif team == teamreapers then spawnPlayer(source, the coords of reapers base) elseif team == teamstalkers then spawnPlayer(source, the coords of stalkers base) end end addEventHandler ( "onPlayerWasted", getRootElement(), player_Wasted ) addEvent( "onTeamSelected", true ) function onTeamSelected( theTeam ) if theTeam then local team = getTeamFromName( ""..theTeam) setPlayerTeam( source, team ) outputChatBox("You joined successfully !" ) end end addEventHandler ( "onTeamSelected", getRootElement(), onTeamSelected ) Client-Side: GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} GUIEditor_Image = {} function warpbasehunters() outputChatBox( "You chose the Hunters's team !" ) visibile() triggerServerEvent("onTeamSelected", getLocalPlayer(), "Hunters" ) end function warpbasereaper() outputChatBox( "You chose the Reapers's team !" ) visibile() triggerServerEvent("onTeamSelected", getLocalPlayer(), "Reapers" ) end function warpbasestalkers() outputChatBox( "You chose the Talkers's team !" ) visibile() triggerServerEvent("onTeamSelected", getLocalPlayer(), "Stalkers" ) end function startup() GUIEditor_Window[1] = guiCreateWindow(0,0,0.99,1,"...SCEGLI UNA FAZIONE...",true) guiSetVisible(GUIEditor_Window[1],false) GUIEditor_Memo[1] = guiCreateMemo(0.0164,0.0517,0.5404,0.56,"21 dicembre 2012...\nLa data piu' conosciuta sulla faccia di\nquesto misero pianeta.\nFino ad un anno prima andava tutto bene,\nfino a quando, per i classici motivi\ndi soldi, non scoppio' l' ennesima,\ndisastrosa, guerra mondiale.\nFurono usate armi biologiche e nucleari,\nfino ad ottenere questo cazzo di risultato...\nUn mondo di merda ricoperto da zombies di merda\ntenuti in vita da quelle radiazioni e da quei composti \nchimici DI MERDA.\nNegli anni seguenti si sono formate diverse comunita':\ngli HUNTERS, i Reaper e gli Stalkers.\nIl tuo compito e' quello di entrare a fare parte di uno di questi\ngruppi e di ammazzare quei fottuti zombies.\nChe cosa stai aspettando ancora? e' il tuo momento.\n",true,GUIEditor_Window[1]) GUIEditor_Image[1] = guiCreateStaticImage(0.5101,0.1017,0.4836,0.4767,"images/mtalogo.png",true,GUIEditor_Window[1]) GUIEditor_Button[1] = guiCreateButton(0.0278,0.8267,0.2374,0.1217,"HUNTERS",true,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(0.3851,0.8267,0.2374,0.1217,"REAPER",true,GUIEditor_Window[1]) GUIEditor_Button[3] = guiCreateButton(0.7172,0.8267,0.2374,0.1217,"STALKERS",true,GUIEditor_Window[1]) GUIEditor_Label[1] = guiCreateLabel(0.2841,0.6783,0.4306,0.0717,"VOGLIO FARE PARTE DEI:",true,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[1],255,255,255) guiLabelSetVerticalAlign(GUIEditor_Label[1],"center") guiLabelSetHorizontalAlign(GUIEditor_Label[1],"center",false) addEventHandler ( "onClientGUIClick", GUIEditor_Button[1], warpbasehunters, true ) addEventHandler ( "onClientGUIClick", GUIEditor_Button[2], warpbasereaper, true ) addEventHandler ( "onClientGUIClick", GUIEditor_Button[3], warpbasestalkers, true ) end addEventHandler("onClientResourceStart",getResourceRootElement(),startup) --opens the gui-- function visibile() if (guiGetVisible(GUIEditor_Window[1])) then showCursor(false) guiSetVisible(GUIEditor_Window[1],false) else showCursor(true) guiSetVisible(GUIEditor_Window[1],true) end end -- addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), visibile)
  19. 1st question why do you add this ?: addEventHandler ( "onClientGUIClick", GUIEditor_Button[1], selezionaskin, false ) addEventHandler ( "onClientGUIClick", GUIEditor_Button[2], selezionaskin, false ) addEventHandler ( "onClientGUIClick", GUIEditor_Button[3], selezionaskin, false )
  20. onElementDataChange is triggered when the server make a setElementData Where is your setElementData( thePlayer,"Experience", something+somethingElse )
  21. Sorry, but your script is wrong ! The correct script: teamhunters = createTeam ("Hunters", 0, 255, 0 ) teamreapers = createTeam ("Reapers", 200, 0, 100 ) teamstalkers = createTeam ( "Stalkers", 200, 0, 100 ) function player_Wasted() team = getPlayerTeam (source) if team == teamhunters then --blabla end if team == teamreapers then --blabla end if team == teamstalkers then --blabla end end addEventHandler ( "onPlayerWasted", getRootElement(), player_Wasted )
  22. So... If you want to retreive a value from a table, you have to do: Tablelevels[theRow][theColumn]! The final code: Tablelevels = {} Tablelevels[0] = { "25", "100"} Tablelevels[1] = { "100", "150"} Tablelevels[2] = { "150", "200"} Tablelevels[3] = { "200", "500"} function Thislevelup() local dataElement1 = getElementData(source,"Experience") for k,i in ipairs( Tablelevels ) do if tostring(dataElement1) == tostring(Tablelevels[k][1]) then local addLevel = getElementData(source,"Level") or 0 addLevel = tonumber(addLevel)+1 -- tonumber for security setElementData( source, "Level", addLevel ) local addNextLevel = getElementData(source,"NextLevel") or 0 addNextLevel = addNextLevel + tonumber(Tablelevels[k][2]) setElementData( source, "NextLevel", addNextLevel ) outputChatBox("New Level") end end end addEventHandler("onElementDataChange",getRootElement(),Thislevelup) You want to retreive the row where the player's experience correspond: For exemple: if the player's experience is 25, so the good line is Tablelevels[0]. So you test each table line like this: for k,i in ipairs( Tablelevels ) do -- k start to 0 ( so I start your table with 0 ) if tostring(dataElement1) == tostring(Tablelevels[k][1]) then -- ( 1st loop k=0 ) if "25" == Tablelevels[0][1] then => if "25" == "25" then outputChatBox("New Level") addNextLevel = addNextLevel + tonumber(Tablelevels[k][2]) -- ( 1st loop k=0 ) so: tonumber(Tablelevels[0][2]) => tonumber( "100" ) ( You can't increment 2 strings, so you have to make tonumber instead of tostring ) end end
  23. Server: function JoinStartLevel() local EXP = setElementData(source,"Experience",0) local Level = setElementData(source,"Level",1) local exptolevel = setElementData ( source, "NextLevel", 25 ) outputDebugString("PLayer Join "..tostring(EXP,Level,exptolevel)) end addEventHandler("onPlayerJoin", getRootElement(),JoinStartLevel) Client: addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), function( ) if ( getElementData( getLocalPlayer(), "Joined" ) ~= true ) then local EXP1 = getElementData(gme,"Experience") local Level1 = getElementData(gme,"Level") local exptolevel1 = getElementData(gme,"NextLevel") outputChatBox ( "Player Resource start "..tostring(EXP1).." "..tostring(Level1).." "..tostring(exptolevel1).." "..tostring(gme)) LevelsLabel = guiCreateLabel(0.8578,0.6104,0.125,0.0244,"Level: "..tostring(Level1),true) EXPLabel = guiCreateLabel(0.8578,0.6387,0.125,0.0244,"EXP: "..tostring(EXP1).." / "..tostring(exptolevel1),true) setElementData( getLocalPlayer(), "Joined", true ) end end )
  24. Mmmm that's strange, try this: addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), function( ) if ( getElementData( getLocalPlayer(), "Joined" ) ~= true ) then local EXP1 = getElementData(gme,"Experience",tostring) local Level1 = getElementData(gme,"Level",tostring) local exptolevel1 = getElementData(gme,"NextLevel",tostring) outputChatBox ( "Player Resource start "..tostring(EXP1).." "..tostring(Level1).." "..tostring(exptolevel1).." "..tostring(gme)) LevelsLabel = guiCreateLabel(0.8578,0.6104,0.125,0.0244,"Level: "..Level1,true) EXPLabel = guiCreateLabel(0.8578,0.6387,0.125,0.0244,"EXP: "..EXP1.." / "..exptolevel1,true) setElementData( getLocalPlayer(), "Joined", true ) end end )
×
×
  • Create New...