Jump to content

Some Help in getPlayesName and BindKey


Evil-Cod3r

Recommended Posts

Hi all iam try Making a window with Players Name if Player Select a Player He see his Level and Exp

  
GUIEditor_Window = {} 
GUIEditor_Label = {} 
GUIEditor_Grid = {} 
GUIEditor_Image = {} 
  
GUIEditor_Window[1] = guiCreateWindow(423,220,477,311,"Level_System v3.0 ",false) 
guiWindowSetMovable(GUIEditor_Window[1],false) 
guiWindowSetSizable(GUIEditor_Window[1],false) 
GUIEditor_Grid[1] = guiCreateGridList(9,21,264,281,false,GUIEditor_Window[1]) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
for id, playeritem in ipairs(getElementsByType("player")) do  
local row = guiGridListAddRow ( playerList ) 
guiGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ), false, false ) 
guiGridListAddColumn(GUIEditor_Grid[1],"Players",0.2) 
  
for i = 1, 1 do 
    guiGridListAddRow(GUIEditor_Grid[1]) 
end 
GUIEditor_Label[1] = guiCreateLabel(286,43,144,23,"Level :",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[1],0,255,0) 
guiSetFont(GUIEditor_Label[1],"clear-normal") 
GUIEditor_Label[2] = guiCreateLabel(284,95,102,21,"EXP:",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[2],0,0,255) 
guiSetFont(GUIEditor_Label[2],"clear-normal") 
GUIEditor_Image[1] = guiCreateStaticImage(266,152,182,146,"images/mtalogo.png",false,GUIEditor_Window[1]) 
  

and this small script wont work :(

local x,y = guiGetScreenSize()  
  
function headshot ( killer, killerweapon, bodypart ) 
if ( killer ) and ( killer ~= source ) then  
local image = guiCreateStaticImage ( x/4, y/5.8, 399,169, "SAMP"..math.random(1,4)..".png", false ) 
guiSetVisible ( image, false ) 
guiSetVisible ( image, true ) 
guiStaticImageLoadImage(image, "SAMP"..math.random(1,4)..".png") 
setTimer (guiSetVisible, 4000, 1, image, false ) 
end 
addEventHandler ( "onClientPlayerWasted", getRootElement(), headshot ) 
  
  
addEventHandler("onPlayerWasted", root, 
function ( ammo, killer, killerweapon, bodypart ) 
    if ( killer ) and ( killer ~= source ) then 
        if (bodypart == 9) then 
            outputChatBox("**OWned->HeadShot !!!+$50**",killer,255,255,0) 
            owned = guiCreateStaticImage(0.45,0.6722,0.0917,0.0533,"images/owned.png",true) 
            guiSetVisible(blood, false) 
            guiSetVisible(blood, true) 
            setTimer (guiSetVisible, 4000, 1, blood, false ) 
            triggerClientEvent(killer,"playWastedSound",killer,"sounds/2.ogg") 
            givePlayerMoney ( killer, 50 ) 
        end 
    else 
        outputChatBox("**Woops Your Dead Try Next Time Noob ! - $5**",source,255,255,0) 
        triggerClientEvent(source,"playWastedSound",source,"sounds/3.ogg") 
        takePlayerMoney( source, 5 ) 
    end 
end) 

just these tow and i well uplode my gamemode and crdits to who help me :)

Link to comment

Window with player names:

  
GUIEditor_Window[1] = guiCreateWindow(423,220,477,311,"Level_System v3.0 ",false) 
guiWindowSetMovable(GUIEditor_Window[1],false) 
guiWindowSetSizable(GUIEditor_Window[1],false) 
GUIEditor_Grid[1] = guiCreateGridList(9,21,264,281,false,GUIEditor_Window[1]) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
local row = guiGridListAddRow ( playerList ) 
local col = guiGridListAddColumn(GUIEditor_Grid[1],"Players",0.2) 
GUIEditor_Label[1] = guiCreateLabel(286,43,144,23,"Level :",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[1],0,255,0) 
guiSetFont(GUIEditor_Label[1],"clear-normal") 
GUIEditor_Label[2] = guiCreateLabel(284,95,102,21,"EXP:",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[2],0,0,255) 
guiSetFont(GUIEditor_Label[2],"clear-normal") 
GUIEditor_Image[1] = guiCreateStaticImage(266,152,182,146,"images/mtalogo.png",false,GUIEditor_Window[1]) 
  
for i, players in ipairs(getElementsByType('player')) do 
 guiGridListSetItemText(GUIEditor_Grid[1],row,col,getPlayerName(players),false,false) 
end 
  
addEventHandler('onClientGUIClick',root, 
 function() 
  if source == GUIEditor_Grid[1] then 
     local theRow, theCol = guiGridListGetSelectedItem(source) 
     if theRow and theCol and theRow ~= -1 and theCol ~= -1 then 
       local name = guiGridListGetItemText(source,theRow, theCol) 
       --now use your head and script all, because we don't have the level and exp system then we can't make all for you 
    end 
end) 
  

Headshot system:

Client side:

local x,y = guiGetScreenSize()  
  
function headshot ( killer, killerweapon, bodypart ) 
  if ( killer ) and ( killer ~= source ) then  
         local image = guiCreateStaticImage ( x/4, y/5.8, 399,169, "SAMP"..math.random(1,4)..".png", false ) 
         setTimer (guiSetVisible, 4000, 1, image, false ) 
     end 
end 
addEventHandler ( "onClientPlayerWasted", getRootElement(), headshot ) 

Server side:

addEventHandler("onPlayerWasted", root, 
  function ( ammo, killer, killerweapon, bodypart ) 
    if ( killer ) and ( killer ~= source ) then 
      if (bodypart == 9) then 
          outputChatBox("**OWned->HeadShot !!!+$50**",killer,255,255,0) 
          local owned = guiCreateStaticImage(0.45,0.6722,0.0917,0.0533,"images/owned.png",true) 
          setTimer (guiSetVisible, 4000, 1, owned, false ) 
          triggerClientEvent(killer,"playWastedSound",killer,"sounds/2.ogg") 
          givePlayerMoney ( killer, 50 ) 
      end 
   else 
         outputChatBox("**Woops Your Dead Try Next Time Noob ! - $5**",killer,255,255,0) 
         triggerClientEvent(source,"playWastedSound",killer,"sounds/3.ogg") 
         takePlayerMoney( killer, 5 ) 
     end 
end) 

Link to comment
function me2 () 
GUIEditor_Window[1] = guiCreateWindow(423,220,477,311,"Level_System v3.0 ",false) 
guiWindowSetMovable(GUIEditor_Window[1],false) 
guiWindowSetSizable(GUIEditor_Window[1],false) 
GUIEditor_Grid[1] = guiCreateGridList(9,21,264,281,false,GUIEditor_Window[1]) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
local row = guiGridListAddRow ( playerList ) 
local col = guiGridListAddColumn(GUIEditor_Grid[1],"Players",0.2) 
GUIEditor_Label[1] = guiCreateLabel(286,43,144,23,"Level :",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[1],0,255,0) 
guiSetFont(GUIEditor_Label[1],"clear-normal") 
GUIEditor_Label[2] = guiCreateLabel(284,95,102,21,"EXP:",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[2],0,0,255) 
guiSetFont(GUIEditor_Label[2],"clear-normal") 
GUIEditor_Image[1] = guiCreateStaticImage(266,152,182,146,"images/mtalogo.png",false,GUIEditor_Window[1]) 
for i, players in ipairs(getElementsByType('player')) do 
 guiGridListSetItemText(GUIEditor_Grid[1],row,col,getPlayerName(players),false,false) 
end 
  
addEventHandler('onClientGUIClick',root, 
function() 
if source == GUIEditor_Grid[1] then 
     local theRow, theCol = guiGridListGetSelectedItem(source) 
     if theRow and theCol and theRow ~= -1 and theCol ~= -1 then 
       local name = guiGridListGetItemText(source,theRow, theCol) 
end) 

dont work its say

unexpected symbol near ')'

Link to comment

lol? Only copy mine and test, you created a function and dont closed it.

  
GUIEditor_Window[1] = guiCreateWindow(423,220,477,311,"Level_System v3.0 ",false) 
guiWindowSetMovable(GUIEditor_Window[1],false) 
guiWindowSetSizable(GUIEditor_Window[1],false) 
GUIEditor_Grid[1] = guiCreateGridList(9,21,264,281,false,GUIEditor_Window[1]) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
local row = guiGridListAddRow ( playerList ) 
local col = guiGridListAddColumn(GUIEditor_Grid[1],"Players",0.2) 
GUIEditor_Label[1] = guiCreateLabel(286,43,144,23,"Level :",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[1],0,255,0) 
guiSetFont(GUIEditor_Label[1],"clear-normal") 
GUIEditor_Label[2] = guiCreateLabel(284,95,102,21,"EXP:",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[2],0,0,255) 
guiSetFont(GUIEditor_Label[2],"clear-normal") 
GUIEditor_Image[1] = guiCreateStaticImage(266,152,182,146,"images/mtalogo.png",false,GUIEditor_Window[1]) 
  
for i, players in ipairs(getElementsByType('player')) do 
 guiGridListSetItemText(GUIEditor_Grid[1],row,col,getPlayerName(players),false,false) 
end 
  
addEventHandler('onClientGUIClick',root, 
 function() 
  if source == GUIEditor_Grid[1] then 
     local theRow, theCol = guiGridListGetSelectedItem(source) 
     if theRow and theCol and theRow ~= -1 and theCol ~= -1 then 
       local name = guiGridListGetItemText(source,theRow, theCol) 
       --now use your head and script all, because we don't have the level and exp system then we can't make all for you 
    end 
end) 
  

Link to comment

Aw, my bad, I forgot a end.

addEventHandler('onClientGUIClick',root, 
 function() 
  if source == GUIEditor_Grid[1] then 
     local theRow, theCol = guiGridListGetSelectedItem(source) 
     if theRow and theCol and theRow ~= -1 and theCol ~= -1 then 
       local name = guiGridListGetItemText(source,theRow, theCol) 
       --now use your head and script all, because we don't have the level and exp system then we can't make all for you 
    end 
  end 
end) 

Link to comment

its work but dont get the Players Name :(

function sa () 
GUIEditor_Window = {} 
GUIEditor_Grid = {} 
GUIEditor_Label = {} 
GUIEditor_Image = {} 
GUIEditor_Window[1] = guiCreateWindow(423,220,477,311,"Level_System v3.0 ",false) 
guiWindowSetMovable(GUIEditor_Window[1],false) 
guiWindowSetSizable(GUIEditor_Window[1],false) 
GUIEditor_Grid[1] = guiCreateGridList(9,21,264,281,false,GUIEditor_Window[1]) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
local row = guiGridListAddRow ( playerList ) 
local col = guiGridListAddColumn(GUIEditor_Grid[1],"Players",0.2) 
GUIEditor_Label[1] = guiCreateLabel(286,43,144,23,"Level :",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[1],0,255,0) 
guiSetFont(GUIEditor_Label[1],"clear-normal") 
GUIEditor_Label[2] = guiCreateLabel(284,95,102,21,"EXP:",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[2],0,0,255) 
guiSetFont(GUIEditor_Label[2],"clear-normal") 
GUIEditor_Image[1] = guiCreateStaticImage(266,152,182,146,"images/mtalogo.png",false,GUIEditor_Window[1]) 
  
for i, players in ipairs(getElementsByType('player')) do 
 guiGridListSetItemText(GUIEditor_Grid[1],row,col,getPlayerName(players),false,false) 
end 
addEventHandler ( "onClientResourceStart", getRootElement(), sa ) 
  
addEventHandler('onClientGUIClick',root, 
 function() 
  if source == GUIEditor_Grid[1] then 
     local theRow, theCol = guiGridListGetSelectedItem(source) 
     if theRow and theCol and theRow ~= -1 and theCol ~= -1 then 
       local name = guiGridListGetItemText(source,theRow, theCol) 
    end 
  end 
end) 
  
function ToggleShop() 
    if guiGetVisible(GUIEditor_Window[1]) == true then 
        guiSetVisible(GUIEditor_Window[1],false) 
        showCursor(false) 
    else 
        guiSetVisible(GUIEditor_Window[1],true) 
        showCursor(true) 
    end 
end 
end 
bindKey("F7","down",ToggleShop) 

Link to comment
  
GUIEditor_Window = {} 
GUIEditor_Grid = {} 
GUIEditor_Label = {} 
GUIEditor_Image = {} 
  
GUIEditor_Window[1] = guiCreateWindow(423,220,477,311,"Level_System v3.0 ",false) 
guiWindowSetMovable(GUIEditor_Window[1],false) 
guiWindowSetSizable(GUIEditor_Window[1],false) 
GUIEditor_Grid[1] = guiCreateGridList(9,21,264,281,false,GUIEditor_Window[1]) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
local row = guiGridListAddRow ( playerList ) 
local col = guiGridListAddColumn(GUIEditor_Grid[1],"Players",0.2) 
GUIEditor_Label[1] = guiCreateLabel(286,43,144,23,"Level :",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[1],0,255,0) 
guiSetFont(GUIEditor_Label[1],"clear-normal") 
GUIEditor_Label[2] = guiCreateLabel(284,95,102,21,"EXP:",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[2],0,0,255) 
guiSetFont(GUIEditor_Label[2],"clear-normal") 
GUIEditor_Image[1] = guiCreateStaticImage(266,152,182,146,"images/mtalogo.png",false,GUIEditor_Window[1]) 
  
if col then 
    for id, players in ipairs(getElementsByType('player')) do 
     guiGridListSetItemText(GUIEditor_Grid[1],row,col,getPlayerName(players),false,false) 
  end 
end 
  
addEventHandler('onClientGUIClick',root, 
 function() 
  if source == GUIEditor_Grid[1] then 
     local theRow, theCol = guiGridListGetSelectedItem(source) 
     if theRow and theCol and theRow ~= -1 and theCol ~= -1 then 
       local name = guiGridListGetItemText(source,theRow, theCol) 
    end 
  end 
end) 
  
bindKey('F7','down', 
 function() 
  guiSetVisible(GUIEditor_Window[1[, not guiGetVisible(GUIEditor_Window[1])) 
  showCursor(not isCursorShowing()) 
end) 

I simplified your bind key function too.

Link to comment
  
GUIEditor_Window = {} 
GUIEditor_Grid = {} 
GUIEditor_Label = {} 
GUIEditor_Image = {} 
  
GUIEditor_Window[1] = guiCreateWindow(423,220,477,311,"Level_System v3.0 ",false) 
guiWindowSetMovable(GUIEditor_Window[1],false) 
guiWindowSetSizable(GUIEditor_Window[1],false) 
GUIEditor_Grid[1] = guiCreateGridList(9,21,264,281,false,GUIEditor_Window[1]) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
row = guiGridListAddRow ( GUIEditor_Grid[1] ) 
col = guiGridListAddColumn(GUIEditor_Grid[1],"Players",0.2) 
GUIEditor_Label[1] = guiCreateLabel(286,43,144,23,"Level :",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[1],0,255,0) 
guiSetFont(GUIEditor_Label[1],"clear-normal") 
GUIEditor_Label[2] = guiCreateLabel(284,95,102,21,"EXP:",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[2],0,0,255) 
guiSetFont(GUIEditor_Label[2],"clear-normal") 
GUIEditor_Image[1] = guiCreateStaticImage(266,152,182,146,"images/mtalogo.png",false,GUIEditor_Window[1]) 
  
if col then 
    for id, players in ipairs(getElementsByType('player')) do 
     guiGridListSetItemText(GUIEditor_Grid[1],row,col,getPlayerName(players),false,false) 
  end 
end 
  
addEventHandler('onClientGUIClick',root, 
 function() 
  if source == GUIEditor_Grid[1] then 
     local theRow, theCol = guiGridListGetSelectedItem(source) 
     if theRow and theCol and theRow ~= -1 and theCol ~= -1 then 
       local name = guiGridListGetItemText(source,theRow, theCol) 
    end 
  end 
end) 
  
bindKey('F7','down', 
 function() 
  guiSetVisible(GUIEditor_Window[1[, not guiGetVisible(GUIEditor_Window[1])) 
  showCursor(not isCursorShowing()) 
end) 

Updated.

Edited by Guest
Link to comment
GUIEditor_Window = {} 
GUIEditor_Grid = {} 
GUIEditor_Label = {} 
GUIEditor_Image = {} 
  
GUIEditor_Window[1] = guiCreateWindow( 423,220,477,311,"Level_System v3.0 ",false ) 
guiWindowSetMovable( GUIEditor_Window[1],false ) 
guiWindowSetSizable( GUIEditor_Window[1],false ) 
GUIEditor_Grid[1] = guiCreateGridList( 9,21,264,281,false,GUIEditor_Window[1] ) 
guiGridListSetSelectionMode( GUIEditor_Grid[1],2 ) 
row = guiGridListAddRow ( GUIEditor_Grid[1] ) 
col = guiGridListAddColumn( GUIEditor_Grid[1],"Players",0.2 ) 
GUIEditor_Label[1] = guiCreateLabel( 286,43,144,23,"Level :",false,GUIEditor_Window[1] ) 
guiLabelSetColor( GUIEditor_Label[1],0,255,0 ) 
guiSetFont( GUIEditor_Label[1],"clear-normal" ) 
GUIEditor_Label[2] = guiCreateLabel( 284,95,102,21,"EXP:",false,GUIEditor_Window[1] ) 
guiLabelSetColor( GUIEditor_Label[2],0,0,255 ) 
guiSetFont( GUIEditor_Label[2],"clear-normal" ) 
GUIEditor_Image[1] = guiCreateStaticImage( 266,152,182,146,"images/mtalogo.png",false,GUIEditor_Window[1] ) 
  
if col then 
    for _, players in pairs( getElementsByType 'player' ) do 
        guiGridListSetItemText( GUIEditor_Grid[1],row,col,getPlayerName( players ),false,false ) 
    end 
end 
  
addEventHandler( 'onClientGUIClick',root, 
    function( ) 
        if source == GUIEditor_Grid[1] then 
            local theRow, theCol = guiGridListGetSelectedItem( source ) 
            if theRow and theCol and theRow ~= -1 and theCol ~= -1 then 
                guiGridListGetItemText( source,theRow, theCol ) 
            end 
        end 
    end 
) 
  
bindKey( 'F7','down', 
    function( ) 
        guiSetVisible( GUIEditor_Window[1], not guiGetVisible( GUIEditor_Window[1] ) ) 
        showCursor( not isCursorShowing( ) ) 
    end 
) 

Your code have syntax error :/

Link to comment
GUIEditor_Window = {} 
GUIEditor_Grid = {} 
GUIEditor_Label = {} 
GUIEditor_Image = {} 
  
GUIEditor_Window[1] = guiCreateWindow( 423,220,477,311,"Level_System v3.0 ",false ) 
guiWindowSetMovable( GUIEditor_Window[1],false ) 
guiWindowSetSizable( GUIEditor_Window[1],false ) 
guiSetVisible( GUIEditor_Window[1],false ) 
GUIEditor_Grid[1] = guiCreateGridList( 9,21,264,281,false,GUIEditor_Window[1] ) 
guiGridListSetSelectionMode( GUIEditor_Grid[1],2 ) 
col = guiGridListAddColumn( GUIEditor_Grid[1],"Players",0.90 ) 
GUIEditor_Label[1] = guiCreateLabel( 286,43,144,23,"Level:",false,GUIEditor_Window[1] ) 
guiLabelSetColor( GUIEditor_Label[1],0,255,0 ) 
guiSetFont( GUIEditor_Label[1],"clear-normal" ) 
GUIEditor_Label[2] = guiCreateLabel( 284,95,102,21,"EXP:",false,GUIEditor_Window[1] ) 
guiLabelSetColor( GUIEditor_Label[2],0,0,255 ) 
guiSetFont( GUIEditor_Label[2],"clear-normal" ) 
GUIEditor_Image[1] = guiCreateStaticImage( 266,152,182,146,"images/mtalogo.png",false,GUIEditor_Window[1] ) 
  
if (col) then 
    for _, player in pairs( getElementsByType 'player' ) do 
        row = guiGridListAddRow ( GUIEditor_Grid[1] ) 
        guiGridListSetItemText( GUIEditor_Grid[1],row,col,getPlayerName( player ),false,false ) 
    end 
end 
  
addEventHandler( 'onClientGUIClick',root, 
    function( ) 
        if (source == GUIEditor_Grid[1]) then 
            local theRow, theCol = guiGridListGetSelectedItem( source ) 
            if (theRow and theCol and theRow ~= -1 and theCol ~= -1) then 
                local playerName = guiGridListGetItemText( source,theRow, theCol ) 
                local player = getPlayerFromName(playerName) 
                if (player and isElement(player)) then 
                    local theEXP = getElementData(player, "ExP") or 0 
                    local theLevel = getElementData(player, "Level") or 0 
                    guiSetText(GUIEditor_Label[1], "Level: ".. tostring(theLevel)) 
                    guiSetText(GUIEditor_Label[2], "EXP: ".. tostring(theEXP)) 
                else 
                    guiSetText(GUIEditor_Label[1], "Level:") 
                    guiSetText(GUIEditor_Label[2], "EXP:") 
                end 
            else 
                guiSetText(GUIEditor_Label[1], "Level:") 
                guiSetText(GUIEditor_Label[2], "EXP:") 
            end 
        end 
    end 
) 
  
bindKey( 'F7','down', 
    function( ) 
        guiSetVisible( GUIEditor_Window[1], not guiGetVisible( GUIEditor_Window[1] ) ) 
        showCursor( guiGetVisible( GUIEditor_Window[1] ) ) 
    end 
) 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...