TheIceman1 Posted February 25, 2013 Posted February 25, 2013 When I start resource, then i have players on grid list, but when i do reconnect then I dont have players on grid list. for id, player in ipairs(getElementsByType("player")) do if (getPlayerWantedLevel(player) > 0) then local row = guiGridListAddRow ( GUIEditor_Grid[1] ) guiGridListSetItemText ( GUIEditor_Grid[1], row, GUIEditor_Column[1], getPlayerName( player ), false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], row, GUIEditor_Column[2], getPlayerWantedLevel( player ), false, false ) end end Need paid scripter just pm me i will accept every job!
K4stic Posted February 25, 2013 Posted February 25, 2013 try this: for _,player in ipairs(getElementsByType("player")) do if (getPlayerWantedLevel(player) > 0) then local row = guiGridListAddRow ( GUIEditor_Grid[1] ) guiGridListSetItemText ( GUIEditor_Grid[1], row, 1, tostring( player [ 1 ] ), getPlayerName( player ), false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], row, 1, tostring( player [ 2 ] ), getPlayerWantedLevel( player )) end end Giving a Fuck? Nope, That isn't in My Skill Set
Castillo Posted February 25, 2013 Posted February 25, 2013 getPlayerWantedLevel only returns the wanted level of the local player if you use it client side. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
TheIceman1 Posted February 26, 2013 Author Posted February 26, 2013 (edited) try this: for _,player in ipairs(getElementsByType("player")) do if (getPlayerWantedLevel(player) > 0) then local row = guiGridListAddRow ( GUIEditor_Grid[1] ) guiGridListSetItemText ( GUIEditor_Grid[1], row, 1, tostring( player [ 1 ] ), getPlayerName( player ), false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], row, 1, tostring( player [ 2 ] ), getPlayerWantedLevel( player )) end end Dont work. @Solidsnake14:But how to put wanted level of players on the grid list? for id, player in ipairs(getElementsByType("player")) do if (getPlayerWantedLevel(player) > 0) then local row = guiGridListAddRow ( GUIEditor_Grid[1] ) guiGridListSetItemText ( GUIEditor_Grid[1], row, GUIEditor_Column[1], getPlayerName( player ), false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], row, GUIEditor_Column[2], getPlayerWantedLevel( player ), false, false ) end end This code showing me players and their wanted levels,but problem is that when i do /reconnect the i cant see players on grid list and their wanted levels. Edited February 26, 2013 by Guest Need paid scripter just pm me i will accept every job!
iPrestege Posted February 26, 2013 Posted February 26, 2013 getPlayerWantedLevel only returns the wanted level of the local player if you use it client side.
K4stic Posted February 26, 2013 Posted February 26, 2013 try this: for _, player in ipairs ( getElementsByType( "player" ) ) do local wanted = getPlayerWantedLevel ( player ) if wanted > 0 then local row = guiGridListAddRow ( GUIEditor_Grid[1] ) guiGridListSetItemText ( GUIEditor_Grid[1], row, 1, GUIEditor_Column[1], getPlayerName( player ), false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], row, 1, GUIEditor_Column[2], wanted, false, false ) end end Giving a Fuck? Nope, That isn't in My Skill Set
TheIceman1 Posted February 26, 2013 Author Posted February 26, 2013 try this: for _, player in ipairs ( getElementsByType( "player" ) ) do local wanted = getPlayerWantedLevel ( player ) if wanted > 0 then local row = guiGridListAddRow ( GUIEditor_Grid[1] ) guiGridListSetItemText ( GUIEditor_Grid[1], row, 1, GUIEditor_Column[1], getPlayerName( player ), false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], row, 1, GUIEditor_Column[2], wanted, false, false ) end end Dont work. Need paid scripter just pm me i will accept every job!
Castillo Posted February 26, 2013 Posted February 26, 2013 You must get the list server side. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
TheIceman1 Posted February 26, 2013 Author Posted February 26, 2013 How to this,I dont understand. Need paid scripter just pm me i will accept every job!
Castillo Posted February 26, 2013 Posted February 26, 2013 Well, you must get the players server side, get their wanted level, insert them on a table, then send it to the client side and add to grid list. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
50p Posted February 26, 2013 Posted February 26, 2013 Please, use events. Doesn't matter if it's simple script or you need to process more action when starting resource. Events are there to be used and onClientResourceStart is one of them. I don't know why gui editor doesn't put all the gui creation in one onClientResourceStart. SKIPPER's code will add players to the grid list ONLY if YOUR (local player) wanted level higher than 0. If that's what you want you can use his code, otherwise you need to communicate with the server/client ((triggerServerEvent and triggerClientEvent) if you want to get all players' wanted level so that you can use it in grid list. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
TheIceman1 Posted February 26, 2013 Author Posted February 26, 2013 Understand,thanks! Need paid scripter just pm me i will accept every job!
TheIceman1 Posted February 27, 2013 Author Posted February 27, 2013 Whats wrong here?Nothing happens. Server: function wantedplayers () local wl = getPlayerWantedLevel ( source ) if wl > 0 then end end addEvent ( "wantedplayers", true ) addEventHandler ( "wantedplayers", root, wantedplayers ) Client: function setplayers () for id, player in ipairs(getElementsByType("player")) do if ( triggerServerEvent ( player, "wantedplayers" ) ) then local row = guiGridListAddRow ( GUIEditor_Grid[1] ) guiGridListSetItemText ( GUIEditor_Grid[1], row, GUIEditor_Column[1], getPlayerName( player ), false, false ) end end end addEventHandler ( "onClientResourceStart", getThisResource(), setplayers ) Need paid scripter just pm me i will accept every job!
iPrestege Posted February 27, 2013 Posted February 27, 2013 Whats wrong here?Nothing happens.Server: function wantedplayers () local wl = getPlayerWantedLevel ( source ) if wl > 0 then end end addEvent ( "wantedplayers", true ) addEventHandler ( "wantedplayers", root, wantedplayers ) Client: function setplayers () for id, player in ipairs(getElementsByType("player")) do if ( triggerServerEvent ( player, "wantedplayers" ) ) then local row = guiGridListAddRow ( GUIEditor_Grid[1] ) guiGridListSetItemText ( GUIEditor_Grid[1], row, GUIEditor_Column[1], getPlayerName( player ), false, false ) end end end addEventHandler ( "onClientResourceStart", getThisResource(), setplayers ) Make No Sense .
TheIceman1 Posted February 27, 2013 Author Posted February 27, 2013 But i dont have an idea how to make it... Need paid scripter just pm me i will accept every job!
K4stic Posted February 27, 2013 Posted February 27, 2013 pls post full client side Giving a Fuck? Nope, That isn't in My Skill Set
TheIceman1 Posted February 27, 2013 Author Posted February 27, 2013 GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Label = {} GUIEditor_Grid = {} GUIEditor_Column = {} GUIEditor_Window[1] = guiCreateWindow(303,111,463,438,"SACR Police computer",false) guiSetVisible ( GUIEditor_Window[1], false ) GUIEditor_Grid[1] = guiCreateGridList(10,26,204,375,false,GUIEditor_Window[1]) GUIEditor_Column[1] = guiGridListAddColumn(GUIEditor_Grid[1],"Wanted player",0.5) GUIEditor_Column[2] = guiGridListAddColumn(GUIEditor_Grid[1],"Wanted player",0.5) GUIEditor_Button[1] = guiCreateButton(9,408,205,21,"Blip player",false,GUIEditor_Window[1]) GUIEditor_Label[1] = guiCreateLabel(218,27,241,74,"My informations:",false,GUIEditor_Window[1]) GUIEditor_Label[2] = guiCreateLabel(226,46,224,27,"Account name:",false,GUIEditor_Window[1]) GUIEditor_Label[3] = guiCreateLabel(226,65,227,27,"Arrests:",false,GUIEditor_Window[1]) GUIEditor_Label[4] = guiCreateLabel(226,85,233,26,"Hours:",false,GUIEditor_Window[1]) GUIEditor_Label[5] = guiCreateLabel(226,106,231,28,"Group:",false,GUIEditor_Window[1]) GUIEditor_Label[6] = guiCreateLabel(216,122,240,51,"Wanted player information:",false,GUIEditor_Window[1]) GUIEditor_Label[7] = guiCreateLabel(229,143,213,27,"Account name:",false,GUIEditor_Window[1]) GUIEditor_Label[8] = guiCreateLabel(229,166,223,21,"Hours:",false,GUIEditor_Window[1]) GUIEditor_Label[9] = guiCreateLabel(227,188,214,22,"Group:",false,GUIEditor_Window[1]) GUIEditor_Label[10] = guiCreateLabel(227,207,221,22,"Wanted level:",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(225,380,224,49,"Close",false,GUIEditor_Window[1]) function setplayers () for id, player in ipairs(getElementsByType("player")) do if ( triggerServerEvent ( player, "wantedplayers" ) ) then local row = guiGridListAddRow ( GUIEditor_Grid[1] ) guiGridListSetItemText ( GUIEditor_Grid[1], row, GUIEditor_Column[1], getPlayerName( player ), false, false ) end end end addEventHandler ( "onClientResourceStart", getThisResource(), setplayers ) Need paid scripter just pm me i will accept every job!
K4stic Posted February 27, 2013 Posted February 27, 2013 Try GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Label = {} GUIEditor_Grid = {} GUIEditor_Column = {} GUIEditor_Window[1] = guiCreateWindow(303,111,463,438,"SACR Police computer",false) guiSetVisible ( GUIEditor_Window[1], false ) GUIEditor_Grid[1] = guiCreateGridList(10,26,204,375,false,GUIEditor_Window[1]) GUIEditor_Column[1] = guiGridListAddColumn(GUIEditor_Grid[1],"Wanted player",0.5) GUIEditor_Column[2] = guiGridListAddColumn(GUIEditor_Grid[1],"Wanted player",0.5) GUIEditor_Button[1] = guiCreateButton(9,408,205,21,"Blip player",false,GUIEditor_Window[1]) GUIEditor_Label[1] = guiCreateLabel(218,27,241,74,"My informations:",false,GUIEditor_Window[1]) GUIEditor_Label[2] = guiCreateLabel(226,46,224,27,"Account name:",false,GUIEditor_Window[1]) GUIEditor_Label[3] = guiCreateLabel(226,65,227,27,"Arrests:",false,GUIEditor_Window[1]) GUIEditor_Label[4] = guiCreateLabel(226,85,233,26,"Hours:",false,GUIEditor_Window[1]) GUIEditor_Label[5] = guiCreateLabel(226,106,231,28,"Group:",false,GUIEditor_Window[1]) GUIEditor_Label[6] = guiCreateLabel(216,122,240,51,"Wanted player information:",false,GUIEditor_Window[1]) GUIEditor_Label[7] = guiCreateLabel(229,143,213,27,"Account name:",false,GUIEditor_Window[1]) GUIEditor_Label[8] = guiCreateLabel(229,166,223,21,"Hours:",false,GUIEditor_Window[1]) GUIEditor_Label[9] = guiCreateLabel(227,188,214,22,"Group:",false,GUIEditor_Window[1]) GUIEditor_Label[10] = guiCreateLabel(227,207,221,22,"Wanted level:",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(225,380,224,49,"Close",false,GUIEditor_Window[1]) function setplayers () for id, player in ipairs(getElementsByType("player")) do if (getPlayerWantedLevel(player) > 0) then local row = guiGridListAddRow ( GUIEditor_Grid[1] ) guiGridListSetItemText ( GUIEditor_Grid[1], row, 1, GUIEditor_Column[1], getPlayerName( player ), false, false ) end end end addEventHandler ( "onClientResourceStart", getThisResource(), setplayers ) Giving a Fuck? Nope, That isn't in My Skill Set
TheIceman1 Posted February 27, 2013 Author Posted February 27, 2013 Try GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Label = {} GUIEditor_Grid = {} GUIEditor_Column = {} GUIEditor_Window[1] = guiCreateWindow(303,111,463,438,"SACR Police computer",false) guiSetVisible ( GUIEditor_Window[1], false ) GUIEditor_Grid[1] = guiCreateGridList(10,26,204,375,false,GUIEditor_Window[1]) GUIEditor_Column[1] = guiGridListAddColumn(GUIEditor_Grid[1],"Wanted player",0.5) GUIEditor_Column[2] = guiGridListAddColumn(GUIEditor_Grid[1],"Wanted player",0.5) GUIEditor_Button[1] = guiCreateButton(9,408,205,21,"Blip player",false,GUIEditor_Window[1]) GUIEditor_Label[1] = guiCreateLabel(218,27,241,74,"My informations:",false,GUIEditor_Window[1]) GUIEditor_Label[2] = guiCreateLabel(226,46,224,27,"Account name:",false,GUIEditor_Window[1]) GUIEditor_Label[3] = guiCreateLabel(226,65,227,27,"Arrests:",false,GUIEditor_Window[1]) GUIEditor_Label[4] = guiCreateLabel(226,85,233,26,"Hours:",false,GUIEditor_Window[1]) GUIEditor_Label[5] = guiCreateLabel(226,106,231,28,"Group:",false,GUIEditor_Window[1]) GUIEditor_Label[6] = guiCreateLabel(216,122,240,51,"Wanted player information:",false,GUIEditor_Window[1]) GUIEditor_Label[7] = guiCreateLabel(229,143,213,27,"Account name:",false,GUIEditor_Window[1]) GUIEditor_Label[8] = guiCreateLabel(229,166,223,21,"Hours:",false,GUIEditor_Window[1]) GUIEditor_Label[9] = guiCreateLabel(227,188,214,22,"Group:",false,GUIEditor_Window[1]) GUIEditor_Label[10] = guiCreateLabel(227,207,221,22,"Wanted level:",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(225,380,224,49,"Close",false,GUIEditor_Window[1]) function setplayers () for id, player in ipairs(getElementsByType("player")) do if (getPlayerWantedLevel(player) > 0) then local row = guiGridListAddRow ( GUIEditor_Grid[1] ) guiGridListSetItemText ( GUIEditor_Grid[1], row, 1, GUIEditor_Column[1], getPlayerName( player ), false, false ) end end end addEventHandler ( "onClientResourceStart", getThisResource(), setplayers ) Nothing Need paid scripter just pm me i will accept every job!
50p Posted February 27, 2013 Posted February 27, 2013 Can't people read? Are they so lazy? @SKIPPER, Especially you. Read my previous post. You can't use getPlayerWantedLevel in a client-side script to get remote player's wanted level... Also, read wiki if unsure. @TheIceman1, use triggerServerEvent/triggerClientEvent like you did in your last post but you have to remember that triggerServerEvent will not return the results of the event from server-side. Once you trigger server event and process all the data (get all player's wanted level in this case) then you have to send these information back to the client with a table that holds other player's wanted level. If the wanted level is set by your resource, then you can use this function: _setPlayerWantedLevel = setPlayerWantedLevel; function setPlayerWantedLevel( player, level ) setElementData( player, "wantedLevel", leve ); return _setPlayerWantedLevel( player, level ); end So whenever you use setPlayerWantedLevel function, it will call this custom function which will change player's data ("wantedLevel") to whatever level you set. This way you can use the data in client-side script like this: function setplayers () for id, player in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( GUIEditor_Grid[1] ) guiGridListSetItemText ( GUIEditor_Grid[1], row, GUIEditor_Column[1], getPlayerName( player ), false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], row, GUIEditor_Column[2], tostring( getElementData( player, "wantedLevel" ) ), false, false ) end end addEventHandler ( "onClientResourceStart", resourceRoot, setplayers ) - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
TheIceman1 Posted February 27, 2013 Author Posted February 27, 2013 Working,thanks! Need paid scripter just pm me i will accept every job!
TheIceman1 Posted February 27, 2013 Author Posted February 27, 2013 @50p: But this code showing me "false" or "true",not wanted level. I remade this code but this showing me only name not wanted level. Client: function setplayers () for id, player in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( GUIEditor_Grid[1] ) guiGridListSetItemText ( GUIEditor_Grid[1], row, GUIEditor_Column[1], getPlayerName( player ), false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], row, GUIEditor_Column[2], tostring( getElementData( player, "wantedLevel" ) ), false, false ) end end addEventHandler ( "onClientResourceStart", resourceRoot, setplayers ) Server: _getPlayerWantedLevel = getPlayerWantedLevel; function getPlayerWantedLevel( player, level ) setElementData( player, "wantedLevel", level ); return _getPlayerWantedLevel( player ); end Need paid scripter just pm me i will accept every job!
50p Posted February 28, 2013 Posted February 28, 2013 ...If the wanted level is set by your resource, then you can use this function: _setPlayerWantedLevel = setPlayerWantedLevel; function setPlayerWantedLevel( player, level ) setElementData( player, "wantedLevel", leve ); return _setPlayerWantedLevel( player, level ); end So whenever you use setPlayerWantedLevel function, it will call this custom function which will change player's data ("wantedLevel") to whatever level you set. This way you can use the data in client-side script like this: ... You showed getPlayerWantedLevel which is not setPlayerWantedLevel... Why did you change my code? If you don't modify setPlayerWantedLevel the way I did it, you will NOT change player's data, therefore client-side getElementData will return false. If you want to show 0 instead of false simply change the the 2nd gui line to: guiGridListSetItemText ( GUIEditor_Grid[1], row, GUIEditor_Column[2], tostring( getElementData( player, "wantedLevel" ) or 0 ), false, false ) - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
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