TradeCar

Started by PsyChO_KiLLeR, Mar 07, 2015, 09:30 AM

Previous topic - Next topic

rObInX

#15
Quote from: Kratos_ on Mar 07, 2015, 01:46 PM
Quote from: PsyChO_KiLLeR on Mar 07, 2015, 01:34 PMHere local plr = FindPlayer( status[ plr.ID ].name )

Quote from: Kratos_ on Mar 07, 2015, 11:41 AMFindPlayer expects an integer .


No.
He assigned name as boolen.

Make it name = ""; in playerclass.


Fucking provide error from next time.


DizzasTeR


EK.IceFlake

Quote from: Kratos_ on Mar 07, 2015, 11:41 AMlocal plr = FindPlayer( status[ plr.ID ].tname )
tname isn't the member variable of your class . If its a string then it will throw error as FindPlayer expects an integer .
Uhem* When did FindPlayer suddenly start to except an integer?

rObInX

Quote from: NE.CrystalBlue on Mar 07, 2015, 01:56 PM
Quote from: Kratos_ on Mar 07, 2015, 11:41 AMlocal plr = FindPlayer( status[ plr.ID ].tname )
tname isn't the member variable of your class . If its a string then it will throw error as FindPlayer expects an integer .
Uhem* When did FindPlayer suddenly start to except an integer?

It doesn't.
Mind reading above posts before posting?

Kratos_

#19
Quote from: rObInX on Mar 07, 2015, 01:50 PMHe assigned name as boolen.

Yeah I saw that . Somewhere he is using bool & somewhere setting the name to null . In class , name is false ( boolean ) & later
he is setting the name to null . Here :-
status[ player.ID ].name = null
He is supposed to bind an integer with FindPlayer to get an expression of the form :-
@CrystalBlue :-  See this :-
FindPlayer( player.ID )  // Where player.ID is a non-negative value . ( 0 - 99 for 0.4 [ 0 -  Max Player Slot - 1 ] )
In the middle of chaos , lies opportunity.

rObInX

#20
Last time I checked, it worked with string also.

http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/FindPlayer

Kratos_

#21
https://bitbucket.org/stormeus/0.4-squirrel/wiki/Functions

He was doing this :-

local plr = FindPlayer( status[ plr.ID ].name )

In 0.3 , the FindPlayer take either player id or the playername . PlayerName will be a string & id will be in pure integer . Thats why we used this function there ( In 0.3 ) :-

[code]function GetPlayer( plr )
{
    if ( plr )
    {
        if ( IsNum( plr ) )
        {
            plr = FindPlayer( plr.tointeger() );      // Converting "9" to 9
            if ( plr ) return plr;                             // Returning the appropriate player object after making attempt to find & checking if it exists?
            else return false;
        }
    else
        {     
            plr = FindPlayer( plr );                    //  Finding the player from his name 
            if ( plr ) return plr;                          // Once again returning same stuff
            else return false;
        }
    }
    else return false;
}

I haven't tested in 0.4 as I couldn't go ingame due to some reasons . Thats why I'm talking in reference to documentation . But , since I've found function GetPlayerIDFromName( string name )  in 0.4 , I think this can be reduced to :-

function GetPlayer( plr )
{
    if ( plr )
    {
        if ( IsNum( plr ) )
        {
            plr = FindPlayer( plr.tointeger() );      // Converting "9" to 9
            if ( plr ) return plr;                             // Returning the appropriate player object after making attempt to find & checking if it exists?
            else return false;
        }
    else
        {     
            local plr_id = GetPlayerIDFromName( plr );    // Taking a string as input ( Player's Name ) and integer as output ( Player ID )
            local plr_obj = FindPlayer( plr_id );                    //  Taking the Player ID as input & attempting to find the player object 
            if ( plr_obj ) return plr_obj;                          //  Returning the appropriate player object after making attempt to find & checking if it exists?
            else return false;
        }
    }
    else return false;
}
In the middle of chaos , lies opportunity.