Jump to content

PLS help


K4stic

Recommended Posts

realy don't know what to do then one player buy the train and then come and other and buy train he can kill other peds of other players who buy train :/ (all who buy the train can kill the other player peds)

-- Client Side

local pedCoords = { 
[1] = {280.59, -139.83, 1004.06,7,1}, 
[2] = {280.7, -135.64, 1004.06,7,1}, 
[3] = {284.45, -131.24, 1004.06,7,1}, 
[4] = {288.15, -134.05, 1004.06,7,1}, 
[5] = {290.01, -135.76, 1004.06,7,1}, 
[6] = {285.16, -137.9, 1004.06,7,1}, 
[7] = {279.2, -139.89, 1004.06,7,1}, 
[8] = {276.01, -135.35, 1004.06,7,1}, 
[9] = {278.4, -129.79, 1004.06,7,1}, 
[10] = {283.1, -130.99, 1004.06,7,1}, 
[11] = {289.98, -128.18, 1004.06,7,1}, 
[12] = {295.72, -129.21, 1004.06,7,1} 
} 
  
function startFiringRange() 
    guiSetVisible(guiRangeWindow,false) 
    showCursor(false) 
    if ( getPlayerMoney(localPlayer) >= 250 ) then 
        triggerServerEvent("takePlayerTrainingMoney", localPlayer) 
        if (getElementInterior(localPlayer) == 7) then 
            for i=1,#pedCoords do 
                theTestPeds[i] = createPed(math.random(168,189),pedCoords[i][1],pedCoords[i][2],pedCoords[i][3] +0.5, 269) 
                theTestPedsCount = theTestPedsCount +1 
                setElementData( theTestPeds[i], "weaponTrainPed", true ) 
                setElementInterior( theTestPeds[i], 7 ) 
                setElementDimension( theTestPeds[i], getElementDimension(localPlayer) ) 
            end 
            addEventHandler( "onClientRender", root, onClientRenderWeaponTraining ) 
            shootingTimer = setTimer ( onWeaponTrainingEnd, 120000, 1, false ) 
            isPlayerDoingTest = true 
        end 
    else 
    exports.SCGhelp:createNewHelpMessage("You don't have enough money for the training!",255,0,0,true) 
end 
end 
  
addEventHandler("onClientPedWasted", root, 
    function( killer, weapon, bodypart ) 
        if ( getElementData ( source, "weaponTrainPed" ) ) and ( killer == localPlayer ) then 
            theTestPedsCount = theTestPedsCount -1 
        end 
    end 
) 
  
addEventHandler("onClientPedDamage", root, 
    function( attacker, weapon, bodypart ) 
        if ( isElement( attacker ) ) then 
            if ( getElementData ( source, "weaponTrainPed" ) ) and ( attacker == localPlayer ) then 
                if not ( ( allowedWeapons[getPedWeapon ( localPlayer )] ) ) then 
                    exports.SCGhelp:createNewHelpMessage("You can't use this weapon to train!",255,0,0,true) 
                    cancelEvent() 
                    return 
                elseif ( playerTestWeapon == nil ) then 
                    playerTestWeapon = getPedWeapon ( localPlayer ) 
                    return 
                elseif ( playerTestWeapon ~= getPedWeapon ( localPlayer ) ) then 
                    exports.SCGhelp:createNewHelpMessage("You need to use the same weapon for the whole training!",255,0,0,true) 
                    cancelEvent() 
                    return 
                end 
            end 
        end 
    end 
) 
  

EDIT: Code not full only some parts

Link to comment
  • Moderators

Note:

You already have a index. :) No need to re-index "[1]=",

Only when you use keys or value's like this:

local pedCoords = {["hey"]=-1, ["hey2"]=0, [1]=10, [2]=99, [3]=100, [4]=400} 
  

local pedCoords = { 
{280.59, -139.83, 1004.06,7,1}, 
{280.7, -135.64, 1004.06,7,1}, 
{284.45, -131.24, 1004.06,7,1}, 
{288.15, -134.05, 1004.06,7,1}, 
{290.01, -135.76, 1004.06,7,1}, 
{285.16, -137.9, 1004.06,7,1}, 
{279.2, -139.89, 1004.06,7,1}, 
{276.01, -135.35, 1004.06,7,1}, 
{278.4, -129.79, 1004.06,7,1}, 
{283.1, -130.99, 1004.06,7,1}, 
{289.98, -128.18, 1004.06,7,1}, 
{295.72, -129.21, 1004.06,7,1} 
} 

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