Jump to content

[Ajuda] random weapon


Recommended Posts

  • Moderators

Use estas funções e evento:

createMarker 
getPlayerMoney 
takePlayerMoney 
giveWeapon 
"onMarkerHit" 
math.random 

Para os IDs das armas, você pode usar math.random(2, 34) (de Golf Club até Sniper Rifle) ou escolher outro ID inicial e final.

Ou você pode também definir os IDs numa tabela.

Link to comment

Então estive a criar o script e testei-o no meu servidor ele ao inicio apresentou erros mas eu corrigi eles todos, e agora não apresenta nenhum erro mas, ao entrar no "marker", ele não esta a dar uma arma (random), nem retira o dinheiro ao entrar..

:/

Editado: DNL poderia mandar o codigo por PM, não queria que o codigo fosse roubado :/ visto que e o meu primeiro script..

Muito obrigado :)

Link to comment

Use este, ou tente achar o erro no seu através dele:

(testado)

Marker = createMarker(x,y,z,"cylinder",size,red,green,blue,alpha) 
Armas = { 
{28,200}, -- 28 = Uzi | 200 = Munição 
{29,200}, 
{30,200}, 
{31,200}, 
} 
addEventHandler("onMarkerHit",Marker,function(hitElement) 
    if getElementType(hitElement) == "player" then 
        Money = getPlayerMoney(hitElement) 
        if Money and Money >= 1000 then 
            n = math.random(#Armas) 
            takePlayerMoney(hitElement,1000) 
            giveWeapon(hitElement,Armas[n][1],Armas[n][2]) 
            outputChatBox("Arma "..getWeaponNameFromID(Armas[n][1]).." adquirida com sucesso por $1000!",hitElement,255,255,255,true) 
        else 
            outputChatBox("Você não possui $1000!",hitElement,255,0,0,true) 
        end 
    end 
end) 
  

Link to comment
sera algum problema na munição?
Use este, ou tente achar o erro no seu através dele:

(testado)

Marker = createMarker(x,y,z,"cylinder",size,red,green,blue,alpha) 
Armas = { 
{28,200}, -- 28 = Uzi | 200 = Munição 
{29,200}, 
{30,200}, 
{31,200}, 
} 
addEventHandler("onMarkerHit",Marker,function(hitElement) 
    if getElementType(hitElement) == "player" then 
        Money = getPlayerMoney(hitElement) 
        if Money and Money >= 1000 then 
            n = math.random(#Armas) 
            takePlayerMoney(hitElement,1000) 
            giveWeapon(hitElement,Armas[n][1],Armas[n][2]) 
            outputChatBox("Arma "..getWeaponNameFromID(Armas[n][1]).." adquirida com sucesso por $1000!",hitElement,255,255,255,true) 
        else 
            outputChatBox("Você não possui $1000!",hitElement,255,0,0,true) 
        end 
    end 
end) 
  

Só para informar, o problema já foi resolvido.

@PM:

Muito obrigado DNL, agora funciona perfeitamente! :)

Obrigado pela ajuda de todos

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