Jump to content

[HELP] I need someone to give me 3 codes


EmBaby85

Recommended Posts

Hello guys,

Can someone tell me how should I fix those problems?

-

function peds(ped) 
  for k, v in pairs(pedss) do 
    ped = createPed (v[1], v[2], v[3], v[4], v[5]) 
    giveWeapon( ped, v[6], 9999, true ) 
    setElementFrozen ( ped, true ) 
    if blip then 
    createBlip( v[2], v[3], v[4], 34, 2, 0, 0, 255 ) 
    end 
  end 
end 
addEventHandler("onResourceStart", resourceRoot, peds) 

- How to make this ped shoots or how to make it doesn't get killed?

- How to put an animation or it? "setPedAnimation( ped1, "ped", "WOMAN_walknorm")" Can someone tell me where can I find "ped" and "WOMAN_walknorm"? I want to change them but idk other anim names, I hope you understand me.

- How to make a button that take specifec amount of ammo of X weapon?

I hope you answer me and Thank you :)

Link to comment

KariiM, here's the code.

local blip = true 
local pedss = { 
    {"113", "-2151.9", "-136.9", "36.5", "280", "31", false}, -- RPG dealer 
} 
  
  
function peds(ped) 
  for k, v in pairs(pedss) do 
    ped = createPed (v[1], v[2], v[3], v[4], v[5]) 
    giveWeapon( ped, v[6], 9999, true ) 
    setElementFrozen ( ped, true ) 
    if blip then 
    createBlip( v[2], v[3], v[4], 34, 2, 0, 0, 255 ) 
    end 
  end 
end 
addEventHandler("onResourceStart", resourceRoot, peds) 

Link to comment

--Server side:

local myTable = { --Creating our table we named it "myTable",now we'll stores on it the datas. 
--skinID, x, y, z, rotation, weapons 
 {113, -2151.9, -136.9, 36.5, 280, 31},  
} 
  
 addEventHandler("onResourceStart", resourceRoot, 
function () --No need to define any source in this function since we are using onResourceStart event. 
  for index, v in pairs(myTable) do --Now, we have to loop the datas from "myTable" in this situation we need to use ipairs but no matter if we used pairs in this case too 
    local ped = createPed (v[1], v[2], v[3], v[4], v[5]) 
    local blip = createBlip( v[2], v[3], v[4], 34, 2, 0, 0, 255 ) 
    setElementVisibleTo(blip, root, true)   --we make the blip visible for all players 
    setElementData(ped, "myped", true) --we stock the ped with the key "myped" for getting it later 
    giveWeapon( ped, v[6], 9999, true ) 
    setElementFrozen ( ped, true ) 
    setTimer(setPedAnimation, 3000, 0, ped,"ped", "WOMAN_walknorm") --we set the animation to the defined Ped "ped", adding unlimited time each 3secs the animation will be refreshed. 
  end 
end) 

--Client side:

addEventHandler("onClientPedDamage",getRootElement(), --This event is for when the ped get damages 
function () 
    if getElementData(source,"myped") then --Now we recovering the ped from the data 
        cancelEvent() --we cancel the event to cancel any damages hit our ped 
    end 
end) 

~Have fun scripting

Regards,

KariM

Link to comment
You're more than an awesome guy,

REALLY THANK YOU!

qpjlt0.jpg

Glad to hear that, you're welcome

by the way, what do you mean by this 3rd question, How to make a button that take specifec amount of ammo of X weapon?

Which weapon?

Oh yeah, now i know but can you tell me how to get player's ammo number?

- I put takeWeapon, GetPlayerAmmo and givePlayerMoney but now when I press on it, I get money while I don't have RPGs any solution? :\

Link to comment

Oh yeah, now i know but can you tell me how to get player's ammo number?

- I put takeWeapon, GetPlayerAmmo and givePlayerMoney but now when I press on it, I get money while I don't have RPGs any solution? :\

So you want to make GUI with button, if you pressed it ,it will tell you how much total ammo the ped have , the ped that has been created in the preview script or player?

Link to comment

Oh yeah, now i know but can you tell me how to get player's ammo number?

- I put takeWeapon, GetPlayerAmmo and givePlayerMoney but now when I press on it, I get money while I don't have RPGs any solution? :\

So you want to make GUI with button, if you pressed it ,it will tell you how much total ammo the ped have , the ped that has been created in the preview script or player?

No no, well see. Actually I'm working on RPG dealer system, this ped will sell RPGs (some RP) and I made it so when someone hit the marker, RPG panel pops and I succeded on giving client weapon and take his money, now I want to put new button "Sell RPG" for x amount of money. When I made it to be like that, it worked even while the client hadn't RPG ammo (not the ped)

Link to comment

No no, well see. Actually I'm working on RPG dealer system, this ped will sell RPGs (some RP) and I made it so when someone hit the marker, RPG panel pops and I succeded on giving client weapon and take his money, now I want to put new button "Sell RPG" for x amount of money. When I made it to be like that, it worked even while the client hadn't RPG ammo (not the ped)

Ah i think i got you, put the code here if you won't ,send it via pm i can complet it and clear it from bugs

Link to comment
function sellRPGfunc(ammo, money) 
setPedWeaponSlot ( source, 35, true ) 
if (getPedTotalAmmo ( source ) >= 50) then 
givePlayerMoney(source, tonumber(money)) 
takeWeapon (source, 35, tonumber(ammo)) 
outputChatBox("Successfully: I've bought "..tonumber(ammo).." from you, Thank you!", source, 70, 205, 20, true) 
end 
end 
  
addEvent( "SellRPG", true ) 
addEventHandler( "SellRPG", getRootElement(), sellRPGfunc ) 

Client:

function sell(player) 
triggerServerEvent ( "SellRPG", getLocalPlayer(), "50","50000" ) 
end 
addEventHandler ("onClientGUIClick", closed, sell, false) 
  

Link to comment

I want to put a button on my gui (RPG dealer). when player click at it he gets 100k $ and lose 50 RPGs (if player doesn't have RPGs then he wont get money) I hope you understand me :\

Yes i understood you but which way you want to make the GUI VISIBLE,

for example when the player hit a marker the gui be visible or else when he click on the ped

Link to comment

I want to put a button on my gui (RPG dealer). when player click at it he gets 100k $ and lose 50 RPGs (if player doesn't have RPGs then he wont get money) I hope you understand me :\

Yes i understood you but which way you want to make the GUI VISIBLE,

for example when the player hit a marker the gui be visible or else when he click on the ped

I already made it onclienthitMarker and it works file, i want it as its.

marker = createMarker ( -2151.9 , -136.9, 36.5 - 1, "cylinder", 1.5, 255, 255, 255, 50 ) 
function openRPGpanel(player) 
triggerClientEvent(player, "ToggleWindow", player, createwin) 
end 
addEventHandler( "onMarkerHit", marker, openRPGpanel ) 

Link to comment

Hey Rands,

As i promised you to solve this , so yeah tonight i was with free time and i focused on your problem, i remade the whole of the code as i cleaned it from bugs.

what you post last time was totally messy and with alot of bugs ,i made a FULL code with all the features that you want and what you need so you have just to edit the names and the custom price of sell event in server side it works like 2k for each rocket, so now the code is with 0 ERROR and safe plus features, i hope that i helped you.

--Copy the code, carefully!

--Client side:

local sx, sy = guiGetScreenSize() 
local client = getLocalPlayer() 
local window = guiCreateWindow((sx-344)/ 2, (sy-191)/ 2, 344, 191, "RPG dealer", false) 
guiSetVisible (window, false) 
guiWindowSetSizable(window,false) 
local memo = guiCreateMemo(9, 18, 326, 77, "Welcome to RPG dealer, here you can buy and sell RPGs, press at the button buy to buy rockets and sell to sell rockets and you'll get money for each rocket you sold to the dealer.", false, window) 
local buyrpg = guiCreateButton(9, 152, 139, 25, "Buy RPG (50Rockets)", false, window) 
local sellrpg = guiCreateButton(9, 123, 139, 25, "Sell RPG", false, window) 
local closewin = guiCreateButton(160, 123, 168, 55, "Close window", false, window) 
local label = guiCreateLabel(14, 97, 117, 20, "100 RPGs for: $100,000", false, window) 
guiSetFont(label, "default-bold-small") 
guiLabelSetColor(label, 254, 254, 254)     
  
addEvent("dealerGUI",true) 
addEventHandler("dealerGUI",root, 
function () 
if ( not guiGetVisible(window)) then 
     guiSetVisible(window,true) 
     showCursor(true) 
   end 
end) 
  
addEventHandler ("onClientGUIClick", root, 
function () 
      if (source == closewin) then 
      guiSetVisible(window,false) 
      showCursor(false) 
     elseif (source == buyrpg) then 
      guiSetVisible(window,false) 
      showCursor(false) 
      triggerServerEvent("dealer_buy_rpg",client,client) 
     elseif (source == sellrpg) then 
      guiSetVisible(window,false) 
      showCursor(false) 
      triggerServerEvent("dealer_sell_rpg",client,client) 
   end 
end) 
  
addEventHandler("onClientPedDamage",getRootElement(),   
function () 
    if getElementData(source,"myped") then  
        cancelEvent()   
    end 
end) 

--Server side:

local myTable = {   
--skinID, x, y, z, rotation, weapons 
 {113, -2151.9, -136.9, 36.5, 280, 31}, 
} 
  
 addEventHandler("onResourceStart", resourceRoot, 
function ()   
  for index, v in pairs(myTable) do   
    local theMarker = createMarker(v[2], v[3], v[4]-1, "cylinder", 1.5, 255, 255, 255, 50) 
    local ped = createPed (v[1], v[2], v[3], v[4], v[5]) 
    local blip = createBlip( v[2], v[3], v[4], 34, 2, 0, 0, 255 ) 
    setElementVisibleTo(blip, root, true)    
    setElementData(ped, "myped", true)   
    giveWeapon( ped, v[6], 9999, true ) 
    setElementFrozen ( ped, true ) 
    --setTimer(setPedAnimation, 3000, 0, ped,"ped", "WOMAN_walknorm")   
    addEventHandler("onMarkerHit",theMarker,MarkerHitS)  
  end 
end)  
  
function MarkerHitS(player, matchingDim) 
    if (player and matchingDim and getElementType(player) == "player" and not isPedInVehicle(player)) then 
    triggerClientEvent(player,"dealerGUI",player) 
  end 
end 
  
--Buy RPG 
addEvent( "dealer_buy_rpg", true ) 
addEventHandler("dealer_buy_rpg", getRootElement(), 
function (client) 
    local money = getPlayerMoney (client) 
    if ( money < 100000 ) then 
    outputChatBox("RPG Dealer: You need $100,000 to buy RPGs from the dealer.", client, 255,0,0) 
  else 
    takePlayerMoney( client, 100000) 
    giveWeapon(client, 35, 50 ) 
    outputChatBox("RPG Dealer: Successfully you bought 50 rockets of RPG.", client, 255,0,0) 
    end 
end) 
  
--Sell RPG 
addEvent( "dealer_sell_rpg", true ) 
addEventHandler("dealer_sell_rpg", getRootElement(), 
function () 
local totalammo = getPedTotalAmmo ( source ) 
local weaponPrice = 2000 
local price = tonumber(totalammo)*tonumber(weaponPrice) 
if ( totalammo >= 50) then 
setPedWeaponSlot ( source, 35, true ) 
givePlayerMoney(source, tonumber(price)) 
takeWeapon (source, 35, tonumber(totalammo)) 
outputChatBox("RPG Dealer: Successfully i've bought "..tonumber(totalammo).." Rockets from you for $"..tonumber(price).." ,Thank you!", source, 0, 255, 0) 
 else 
outputChatBox("RPG Dealer: Show your RPGs if you want to sell them.",source,255,0,0) 
   end 
end)  

-Regards,

KariM

Link to comment
triggerServerEvent from client side 
  
addEvent("doWeapon",true) 
addEventHandler("doWeapon",root,function() 
      if getPlayerMoney(source) >= 100 then 
            takePlayerMoney(source,100) 
            giveWeapon(source,35,1,true) 
      end 
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...