abdalbaset Posted February 8, 2014 Share Posted February 8, 2014 i made this script but whene i start its i can see the ped but its dont have and weps and its not shoting me dubug [15:49:13] ERROR: peds\ped.lua:7: attempt to call global 'setPedControlState' (anil value) lua addEventHandler ( "onResourceStart", getResourceRootElement(), function ( ) ped = createPed ( 191,2493.623,-1668.179,13.343,90) setPedWeaponSlot (ped, 1 ) setPedControlState ( ped,fire,true) end ) meta Link to comment
tosfera Posted February 8, 2014 Share Posted February 8, 2014 setPedControlState is a client-only function, beside that you didn't give the ped a weapon. You just set his slot to melee attacks. Link to comment
Anubhav Posted February 8, 2014 Share Posted February 8, 2014 server.lua addEventHandler ( "onResourceStart", getResourceRootElement(), function ( ) ped = createPed ( 191,2493.623,-1668.179,13.343,90) setPedWeaponSlot (ped,) triggerClientEvent("onPedControl",source) end ) client.lua function triggered() setPedControlState ( ped,fire,true) end addEvent( "onPedControl", true ) addEventHandler( "onPedControl",source, triggered ) You can't use client and server mixed functions. Link to comment
abdalbaset Posted February 8, 2014 Author Share Posted February 8, 2014 now the ped is not spawn [16:25:20] SCRIPT ERROR: peds\peds.lua:5: unexpected symbol near ')' [16:25:20] ERROR: Loading script failed: peds\peds.lua:5: unexpected symbol near ')' Link to comment
myonlake Posted February 8, 2014 Share Posted February 8, 2014 You had a few typos and a couple wrong arguments, try this one. Server-side addEventHandler( "onResourceStart", resourceRoot, function( ) local ped = createPed( 191, 2493.623, -1668.179, 13.343, 90 ) setTimer( function( ped ) if ( not isElement( ped ) ) then return end giveWeapon( ped, 22, 9999, true ) triggerClientEvent( root, "onPedControl", ped ) end, 100, 1, ped ) end ) Client-side addEvent( "onPedControl", true ) addEventHandler( "onPedControl", root, function( ) setPedControlState( source, "fire", true ) end ) Link to comment
abdalbaset Posted February 8, 2014 Author Share Posted February 8, 2014 thanx its working but how to set targer for the ped like shoting the near player? Link to comment
myonlake Posted February 8, 2014 Share Posted February 8, 2014 You can use the onClientRender function in combination of setPedAimTarget, getElementsByType, getElementPosition and getDistanceBetweenPoints3D. It won't be too accurate for all players, but it's enough I suppose. You can later make a col shape around the pedestrian and when someone hits it, just shoot the person till they're dead. Link to comment
abdalbaset Posted February 8, 2014 Author Share Posted February 8, 2014 i made a shape but i dont know how to to the else its kind of hard can you help me Link to comment
abdalbaset Posted February 10, 2014 Author Share Posted February 10, 2014 Client side colsp1=createColSphere ( 2493.623, -1668.179, 13.343, 15 ) addEvent( "onPedControl", true ) addEventHandler( "onPedControl", root, function( ) setPedControlState( source, "fire", true ) end ) function colh(player) -------my problem that idk what to put here to make the ped shooting the player who enter the colshap end addEventHandler("onColShapeHit",colsp1,colh) Server side addEventHandler( "onResourceStart", resourceRoot, function( ) local ped = createPed( 191, 2493.623, -1668.179, 13.343, 90 ) setTimer( function( ped ) if ( not isElement( ped ) ) then return end giveWeapon( ped, 27, 9999, true ) triggerClientEvent( root, "onPedControl", ped ) triggerClientEvent( root, "onColShapeHit", ped ) end, 100, 1, ped ) end ) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now