Jump to content

Stucked, Help.


Recommended Posts

Posted

I'm Trying to make a script to shakehands with another player when command be written so i tried to do it

    function kiss (thePlayer, cmd, otherPlayer) 
    local otherPlayer = exports["ID_System"]:getPlayerFromPartialName(thePlayer, otherPlayer) 
    local x, y, z = getElementPosition(thePlayer) 
    local tx, ty, tz = getElementPosition(otherPlayer) 
                if (getPedOccupiedVehicle(thePlayer) == false and getPedOccupiedVehicle(otherPlayer) == false) and otherPlayer then 
            if (getDistanceBetweenPoints3D(x, y, z, tx, ty, tz)<1) then 
            setPedAnimation (thePlayer, "KISSING", "Grlfrd_Kiss_03", -1, true, false, false ) 
            setPedAnimation (otherPlayer, "KISSING", "Grlfrd_Kiss_03", -1, true, false, false ) 
        end 
    end 
end 
addCommandHandler ("kiss", kiss) 

Errors:

[16:42:47] ERROR: call: failed to call 'ID_System:getPlayerFromPartialName' [string "?"] 
[16:42:47] WARNING: Animation_system\Kiss_Anim\anim.lua:4: Bad argument @ 'getElementPosition' [Expected element at argument 1, got boolean] 
[16:42:47] WARNING: Animation_system\Kiss_Anim\anim.lua:5: Bad argument @ 'getPedOccupiedVehicle' 

Posted
I'm Trying to make a script to shakehands with another player when command be written so i tried to do it
    function kiss (thePlayer, cmd, otherPlayer) 
    local otherPlayer = exports["ID_System"]:getPlayerFromPartialName(thePlayer, otherPlayer) 
    local x, y, z = getElementPosition(thePlayer) 
    local tx, ty, tz = getElementPosition(otherPlayer) 
                if (getPedOccupiedVehicle(thePlayer) == false and getPedOccupiedVehicle(otherPlayer) == false) and otherPlayer then 
            if (getDistanceBetweenPoints3D(x, y, z, tx, ty, tz)<1) then 
            setPedAnimation (thePlayer, "KISSING", "Grlfrd_Kiss_03", -1, true, false, false ) 
            setPedAnimation (otherPlayer, "KISSING", "Grlfrd_Kiss_03", -1, true, false, false ) 
        end 
    end 
end 
addCommandHandler ("kiss", kiss) 

Errors:

[16:42:47] ERROR: call: failed to call 'ID_System:getPlayerFromPartialName' [string "?"] 
[16:42:47] WARNING: Animation_system\Kiss_Anim\anim.lua:4: Bad argument @ 'getElementPosition' [Expected element at argument 1, got boolean] 
[16:42:47] WARNING: Animation_system\Kiss_Anim\anim.lua:5: Bad argument @ 'getPedOccupiedVehicle' 

Any help please?

Posted

That is because ID_system does not return an element, you should check that

Try replacing with this...

local otherPlayer = exports["ID_System"]:getPlayerFromPartialName(otherPlayer) 

Posted
That is because ID_system does not return an element, you should check that

Try replacing with this...

local otherPlayer = exports["ID_System"]:getPlayerFromPartialName(otherPlayer) 

Alright this is the Id_system Function, so what's the problem?>

function getPlayerFromPartialName ( source, player_name, script ) 
    if ( player_name ) then 
        local sucess, value = getNameMatches ( player_name ) 
            if ( sucess ) then 
                local matches = ( type ( value ) == "table" ) and #value or 1 
                if ( matches == 1 ) then 
                    if ( script ) then return value else  
                        local player_nick = getPlayerName ( value ) 
                        local player_id = getElementData ( value, "ID" ) 
                        outputChatBox ( "(" .. player_id .. ") " .. player_nick, source, 255, 255, 0 ) 
                    end  
                else     
                    outputChatBox ( "Players matching your search are: ", source, 255, 255, 0 ) 
                    for k, player in ipairs ( value ) do 
                        local player_nick = getPlayerName ( value[k] ) 
                        local player_id = getElementData ( value[k], "ID" ) 
                        outputChatBox ( "(" .. player_id .. ") " .. player_nick, source, 255, 255, 0 ) 
                    end 
                    return true, true 
                end      
            else 
                if ( script ) then return false else 
                    outputChatBox ( "Players matching your search are: ", source, 255, 255, 0 ) 
                    outputChatBox ( value, source, 255, 0, 0 ) 
                end  
            end 
    end 
end  

Posted
local otherPlayer = exports["ID_System"]:getPlayerFromPartialName(thePlayer, otherPlayer, true) 
if (not otherPlayer) then return end 

Try that, I think it should work

Posted
local otherPlayer = exports["ID_System"]:getPlayerFromPartialName(thePlayer, otherPlayer, true) 
if (not otherPlayer) then return end 

Try that, I think it should work

NOw tried it :

    function kiss (thePlayer, cmd, otherPlayer) 
     
    local otherPlayer = exports["ID_System"]:getPlayerFromPartialName(thePlayer, otherPlayer, true) 
    local x, y, z = getElementPosition(thePlayer) 
    local tx, ty, tz = getElementPosition(otherPlayer) 
            if (not otherPlayer) then return end 
            if (getPedOccupiedVehicle(thePlayer) == false and getPedOccupiedVehicle(otherPlayer) == false) then 
            if (getDistanceBetweenPoints3D(x, y, z, tx, ty, tz)<1) then 
            setPedAnimation (thePlayer, "KISSING", "Grlfrd_Kiss_03", -1, true, false, false ) 
            setPedAnimation (otherPlayer, "KISSING", "Grlfrd_Kiss_03", -1, true, false, false ) 
        end 
    end 
end 
addCommandHandler ("kiss", kiss) 

Still the same errors.

Posted
And it is exported as server side function?

Aha actually i know the problem now and fixed it but now there's another problem here:

help please :/

[23:54:27] WARNING: Animation_system\Kiss_Anim\anim.lua:5: Bad argument @ 'getEl 
ementPosition' [Expected element at argument 1, got nil] 

Posted

local otherPlayer = exports["ID_System"]:getPlayerFromPartialName(thePlayer, otherPlayer) 

A little advice (might not help to solve your problem). Don't reuse variable names, however convenient it seems.

It seems that at first otherPlayer is player's nickname and later otherPlayer is a player element.

Posted
local otherPlayer = exports["ID_System"]:getPlayerFromPartialName(thePlayer, otherPlayer) 

A little advice (might not help to solve your problem). Don't reuse variable names, however convenient it seems.

It seems that at first otherPlayer is player's nickname and later otherPlayer is a player element.

Thanks for your advice, so could you fix it please if you can?

Posted

Alright actually i'm almost got the solution and tried it but still there's a problem:

    function kiss (thePlayer, cmd, arg) 
    if arg then 
    local id = tonumber(arg) 
    if id then 
            otherPlayer = exports.ID_System:getPlayerFromID(id) 
    else 
            otherPlayer = getPlayerFromName (arg) 
    end 
    local x, y, z = getElementPosition(thePlayer) 
    local tx, ty, tz = getElementPosition(otherPlayer) 
                if otherPlayer ~= player then 
                if (getPedOccupiedVehicle(thePlayer) == false and getPedOccupiedVehicle(otherPlayer) == false) then 
                if (getDistanceBetweenPoints3D(x, y, z, tx, ty, tz)<1) then 
                setPedAnimation (thePlayer, "KISSING", "Grlfrd_Kiss_03", -1, true, false, false ) 
                setPedAnimation (otherPlayer, "KISSING", "Grlfrd_Kiss_03", -1, true, false, false ) 
                bindKey (thePlayer, "space", "down", StopCommand) 
                end 
            end 
        end 
    end 
end 
addCommandHandler ("kiss", kiss) 
  
    function StopCommand ( source ) 
    setPedAnimation ( source ) 
    unbindKey ( source, "space", "down", StopCommand) 
    end 

when i try to /kiss thePlayer and not /kiss otherPlayer it work on the air

2- when i write a wrong name i get a couple of Errors:

[11:56:53] WARNING: Animation_system\Kiss_Anim\anim.lua:10: Bad argument @ 'getE 
lementPosition' [Expected element at argument 1, got boolean] 
[11:56:53] WARNING: Animation_system\Kiss_Anim\anim.lua:12: Bad 'ped' pointer @ 
'getPedOccupiedVehicle'(1) 
[11:56:53] WARNING: Animation_system\Kiss_Anim\anim.lua:12: Bad argument @ 'getP 
edOccupiedVehicle' 
[11:56:53] WARNING: Animation_system\Kiss_Anim\anim.lua:13: Bad argument @ 'getD 
istanceBetweenPoints3D' 
[11:56:53] ERROR: Animation_system\Kiss_Anim\anim.lua:13: attempt to compare boo 
lean with number 
  

Posted

You must check if the player exists.

function kiss ( thePlayer, cmd, arg ) 
    if ( arg ) then 
        local id = tonumber ( arg ) 
        if ( id ) then 
            otherPlayer = exports.ID_System:getPlayerFromID ( id ) 
        else 
            otherPlayer = getPlayerFromName ( arg ) 
        end 
        if ( otherPlayer ) then 
            local x, y, z = getElementPosition ( thePlayer ) 
            local tx, ty, tz = getElementPosition ( otherPlayer ) 
            if ( otherPlayer ~= thePlayer ) then 
                if ( getPedOccupiedVehicle ( thePlayer ) == false and getPedOccupiedVehicle ( otherPlayer ) == false ) then 
                    if ( getDistanceBetweenPoints3D ( x, y, z, tx, ty, tz ) < 1 ) then 
                        setPedAnimation ( thePlayer, "KISSING", "Grlfrd_Kiss_03", -1, true, false, false ) 
                        setPedAnimation ( otherPlayer, "KISSING", "Grlfrd_Kiss_03", -1, true, false, false ) 
                        bindKey ( thePlayer, "space", "down", StopCommand ) 
                    end 
                end 
            end 
        end 
    end 
end 
addCommandHandler ( "kiss", kiss ) 
  
function StopCommand ( source ) 
    setPedAnimation ( source ) 
    unbindKey ( source, "space", "down", StopCommand ) 
end 

Posted
You must check if the player exists.
function kiss ( thePlayer, cmd, arg ) 
    if ( arg ) then 
        local id = tonumber ( arg ) 
        if ( id ) then 
            otherPlayer = exports.ID_System:getPlayerFromID ( id ) 
        else 
            otherPlayer = getPlayerFromName ( arg ) 
        end 
        if ( otherPlayer ) then 
            local x, y, z = getElementPosition ( thePlayer ) 
            local tx, ty, tz = getElementPosition ( otherPlayer ) 
            if ( otherPlayer ~= thePlayer ) then 
                if ( getPedOccupiedVehicle ( thePlayer ) == false and getPedOccupiedVehicle ( otherPlayer ) == false ) then 
                    if ( getDistanceBetweenPoints3D ( x, y, z, tx, ty, tz ) < 1 ) then 
                        setPedAnimation ( thePlayer, "KISSING", "Grlfrd_Kiss_03", -1, true, false, false ) 
                        setPedAnimation ( otherPlayer, "KISSING", "Grlfrd_Kiss_03", -1, true, false, false ) 
                        bindKey ( thePlayer, "space", "down", StopCommand ) 
                    end 
                end 
            end 
        end 
    end 
end 
addCommandHandler ( "kiss", kiss ) 
  
function StopCommand ( source ) 
    setPedAnimation ( source ) 
    unbindKey ( source, "space", "down", StopCommand ) 
end 

oh....Thanks man :)

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