Jump to content

setPedStat


Best-Killer

Recommended Posts

Client :

addEventHandler('onClientGUIClick',root, function ( ) 
if ( source == aGuiBuy ) then 
if ( guiGridListGetSelectedItem ( aGuiList ) ~= -1 ) then 
local id,price = guiGridListGetItemText(aGuiList,guiGridListGetSelectedItem(aGuiList),1),guiGridListGetItemText(aGuiList,guiGridListGetSelectedItem(aGuiList),2) 
triggerServerEvent('onBuyWeapon',localPlayer,id,price) 
end 
end 
end 
) 

server :

addEvent('onBuyWeapon',true) 
addEventHandler('onBuyWeapon',root, function ( id , price ) 
if ( tonumber ( price ) and getWeaponIDFromName ( id ) ) then 
if ( getPlayerMoney ( client ) >= tonumber ( price ) ) then 
giveWeapon (client,getWeaponIDFromName(id),30) 
takePlayerMoney ( client , tonumber ( price ) ) 
setPedStat (client,30,1000) 
end 
end 
end 
) 

setPedStat not work

0 errors 0 warining

Link to comment
wtf ninth topic on the one hand, it can not be serious? 2-3'd still understood but 9? You still want only help .. so what is a little learning?

so how i can learn

Normally, here have functions -->

i tried with that

Client :
addEventHandler('onClientGUIClick',root, function ( ) 
if ( source == aGuiBuy ) then 
if ( guiGridListGetSelectedItem ( aGuiList ) ~= -1 ) then 
local id,price = guiGridListGetItemText(aGuiList,guiGridListGetSelectedItem(aGuiList),1),guiGridListGetItemText(aGuiList,guiGridListGetSelectedItem(aGuiList),2) 
triggerServerEvent('onBuyWeapon',localPlayer,id,price) 
end 
end  

if u want help thanks if u won't thanks too

end

)[/lua]

server :

addEvent('onBuyWeapon',true) 
addEventHandler('onBuyWeapon',root, function ( id , price ) 
if ( tonumber ( price ) and getWeaponIDFromName ( id ) ) then 
if ( getPlayerMoney ( client ) >= tonumber ( price ) ) then 
giveWeapon (client,getWeaponIDFromName(id),30) 
takePlayerMoney ( client , tonumber ( price ) ) 
setPedStat (client,30,1000) 
end 
end 
end 
) 

setPedStat not work

0 errors 0 warining

Link to comment
addEvent('onBuyWeapon',true) 
addEventHandler('onBuyWeapon',root, function ( id , price )  
if ( tonumber ( price ) and getWeaponIDFromName ( id ) ) then  
if ( getPlayerMoney ( client ) >= tonumber ( price ) ) then  
takePlayerMoney ( client , tonumber ( price ) ) 
setPedStat(thePlayer, 23, 999) 
end 
end 
end 
) 

bad argument setpestat expected element at agument 1 got nill

Link to comment

You can try this :

addEvent('onBuyWeapon',true) 
addEventHandler('onBuyWeapon',root,  
    function ( id , price ) 
    if ( tonumber ( price ) and getWeaponIDFromName ( id ) ) then 
            if ( getPlayerMoney ( source ) >= tonumber ( price ) ) then 
                    takePlayerMoney ( source , tonumber ( price ) ) 
                        setPedStat ( source, 23, 999 ) 
        end 
    end 
end 
) 

Link to comment
  
addEvent('onBuyWeapon',true) 
addEventHandler('onBuyWeapon',root, function ( id , price, thePlayer) 
if ( tonumber ( price ) and getWeaponIDFromName ( id ) ) then 
if ( getPlayerMoney ( client ) >= tonumber ( price ) ) then 
takePlayerMoney ( client , tonumber ( price ) ) 
setPedStat(thePlayer, 23, 999) 
end 
end 
end 
) 
  

Edited by Guest
Link to comment
You can try this :
addEvent('onBuyWeapon',true) 
addEventHandler('onBuyWeapon',root,  
    function ( id , price ) 
    if ( tonumber ( price ) and getWeaponIDFromName ( id ) ) then 
            if ( getPlayerMoney ( source ) >= tonumber ( price ) ) then 
                    takePlayerMoney ( source , tonumber ( price ) ) 
                        setPedStat ( source, 23, 999 ) 
        end 
    end 
end 
) 

not work 0 warinings 0 errors :/

Link to comment
You can try this :
addEvent('onBuyWeapon',true) 
addEventHandler('onBuyWeapon',root,  
    function ( id , price ) 
    if ( tonumber ( price ) and getWeaponIDFromName ( id ) ) then 
            if ( getPlayerMoney ( source ) >= tonumber ( price ) ) then 
                    takePlayerMoney ( source , tonumber ( price ) ) 
                        setPedStat ( source, 23, 999 ) 
        end 
    end 
end 
) 

not work 0 warinings 0 errors :/

Can you please show me the client side .

Link to comment

[/lua]aGuiForm = nil

_gui = nil

_root = getRootElement()

data={};

addEvent("openGView",true)

function aViewGui ( player )

if ( aGuiForm == nil ) then

local x, y = guiGetScreenSize()

for i=0,9 do

data = {};

end

data[0].weapon="Sniper"

data[1].weapon="Taser"

data[2].weapon="Pistol"

data[3].weapon="MP5"

data[4].weapon="Deagle"

data[5].weapon="Ak-47"

data[6].weapon="M4"

data[7].weapon="Uzi/TEC-9"

data[8].weapon="Sawn-Off"

data[9].weapon="ShotGun"

data[0].price=6000

data[1].price=2500

data[2].price=3000

data[3].price=3500

data[4].price=4500

data[5].price=4500

data[6].price=5000

data[7].price=5000

data[8].price=5500

data[9].price=5500

aGuiForm = guiCreateWindow ( x / 2 - 250, y / 2 - 125, 620, 250, "Skill Shop", false )

aGuiList = guiCreateGridList ( 0.02, 0.09, 0.82, 0.86, true, aGuiForm )

guiGridListAddColumn( aGuiList, "Weapon", 0.50 )

guiGridListAddColumn( aGuiList, "Ammount", 0.80 )

aGuiBuy = guiCreateButton ( 0.86, 0.65, 0.12, 0.09, "Buy", true, aGuiForm )

aGuiClose = guiCreateButton ( 0.86, 0.85, 0.12, 0.09, "Close", true, aGuiForm )

addEventHandler ( "onClientGUIClick", aGuiForm, aClientGuiClick )

aMakeList()

end

guiSetVisible ( aGuiForm, true )

guiBringToFront ( aGuiForm )

showCursor(true)

end

addEventHandler ("openGView", _root, aViewGui)

function aViewGuiClose ( destroy )

if ( ( destroy ) ) then

if ( aGuiForm ) then

removeEventHandler ( "onClientGUIClick", aGuiForm, aClientGuiClick )

destroyElement ( aGuiForm )

aGuiForm = nil

end

else

guiSetVisible ( aGuiForm, false )

end

end

function aClientGuiClick ( button )

if ( button == "left" ) then

if ( source == aGuiClose ) then

aViewGuiClose ( false )

showCursor(false)

elseif ( source == aGuiBuy ) then

aViewGuiClose ( false )

showCursor(false)

end

end

end

function aMakeList ()

guiGridListClear(aGuiList)

for i,v in pairs(data) do

local row = guiGridListAddRow ( aGuiList )

guiGridListSetItemText ( aGuiList, row, 1 , tostring(data.weapon) , false, false )

guiGridListSetItemText ( aGuiList, row, 2 , tostring(data.price) , false, false )

end

end

addEventHandler('onClientGUIClick',root, function ( )

if ( source == aGuiBuy ) then

if ( guiGridListGetSelectedItem ( aGuiList ) ~= -1 ) then

local id,price = guiGridListGetItemText(aGuiList,guiGridListGetSelectedItem(aGuiList),1),guiGridListGetItemText(aGuiList,guiGridListGetSelectedItem(aGuiList),2)

triggerServerEvent('onBuyWeapon',localPlayer,id,price)

end

end

end

)[/lua ]

Link to comment
aGuiForm = nil 
_gui = nil 
_root = getRootElement() 
data={}; 
  
addEvent("openGView",true) 
function aViewGui ( player ) 
    if ( aGuiForm == nil ) then 
        local x, y = guiGetScreenSize() 
        
    for i=0,9 do 
        data[i] = {}; 
    end 
        
        data[0].weapon="Sniper" 
        data[1].weapon="Taser" 
        data[2].weapon="Pistol" 
        data[3].weapon="MP5" 
        data[4].weapon="Deagle" 
        data[5].weapon="Ak-47" 
        data[6].weapon="M4" 
        data[7].weapon="Uzi/TEC-9" 
        data[8].weapon="Sawn-Off" 
        data[9].weapon="ShotGun" 
        data[0].price=6000 
        data[1].price=2500 
        data[2].price=3000 
        data[3].price=3500 
        data[4].price=4500 
        data[5].price=4500 
        data[6].price=5000 
        data[7].price=5000 
        data[8].price=5500 
        data[9].price=5500 
        
        
        aGuiForm = guiCreateWindow ( x / 2 - 250, y / 2 - 125, 620, 250, "Skill Shop", false ) 
        aGuiList = guiCreateGridList ( 0.02, 0.09, 0.82, 0.86, true, aGuiForm ) 
        guiGridListAddColumn( aGuiList, "Weapon", 0.50 ) 
        guiGridListAddColumn( aGuiList, "Ammount", 0.80 ) 
        aGuiBuy = guiCreateButton ( 0.86, 0.65, 0.12, 0.09, "Buy", true, aGuiForm ) 
        aGuiClose = guiCreateButton ( 0.86, 0.85, 0.12, 0.09, "Close", true, aGuiForm ) 
        addEventHandler ( "onClientGUIClick", aGuiForm, aClientGuiClick ) 
        
        aMakeList() 
    end 
    guiSetVisible ( aGuiForm, true ) 
    guiBringToFront ( aGuiForm ) 
    showCursor(true) 
end 
addEventHandler ("openGView", _root, aViewGui) 
  
function aViewGuiClose ( destroy ) 
    if ( ( destroy ) ) then 
    if ( aGuiForm ) then 
    removeEventHandler ( "onClientGUIClick", aGuiForm, aClientGuiClick ) 
            destroyElement ( aGuiForm ) 
            aGuiForm = nil 
        end 
    else 
    guiSetVisible ( aGuiForm, false ) 
    end 
end 
  
function aClientGuiClick ( button ) 
    if ( button == "left" ) then 
    if ( source == aGuiClose ) then 
        aViewGuiClose ( false ) 
        showCursor(false)     
        elseif ( source == aGuiBuy ) then 
        aViewGuiClose ( false ) 
        showCursor(false) 
    end 
    end 
end 
  
function aMakeList () 
        guiGridListClear(aGuiList) 
        for i,v in pairs(data) do 
            local row = guiGridListAddRow ( aGuiList ) 
            guiGridListSetItemText ( aGuiList, row, 1 , tostring(data[i].weapon) , false, false ) 
            guiGridListSetItemText ( aGuiList, row, 2 , tostring(data[i].price) , false, false ) 
        end 
end 
  
addEventHandler('onClientGUIClick',root, function ( ) 
if ( source == aGuiBuy ) then  
if ( guiGridListGetSelectedItem ( aGuiList ) ~= -1 ) then  
local id,price = guiGridListGetItemText(aGuiList,guiGridListGetSelectedItem(aGuiList),1),guiGridListGetItemText(aGuiList,guiGridListGetSelectedItem(aGuiList),2) 
triggerServerEvent('onBuyWeapon',localPlayer,id,price) 
end 
end 
end 
) 

Link to comment
addEvent('onBuyWeapon',true) 
addEventHandler('onBuyWeapon',root, 
    function ( id , price ) 
    if ( tonumber ( price ) and getWeaponIDFromName ( id ) ) then 
            if ( getPlayerMoney ( source ) >= tonumber ( price ) ) then 
            takePlayerMoney ( source , tonumber ( price ) ) 
                setPedStat ( source, 23, 999 ) 
                outputChatBox ( 'OK!',source,255,0,0,true ) 
        end 
    end 
end 
) 

See if it show's the code is ok or not .

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...