Well i create a trade car system but its not working always getting error on 33 line
this is commands
else if ( cmd == "taccept" )
{
local cost = status[ player.ID ].cost
local IDS = status[ player.ID ].id
if ( status[ player.ID ].waiting == false ) ePrivMessage("Error: You dont have pending request.",player)
Always error here else if ( player.Cash < cost ) ePrivMessage("Error: You need $ [ " + cost + " ] to buy this vehicle.",player)
else
{
local plr = FindPlayer( status[ plr.ID ].tname )
QuerySQL( db, "UPDATE Cars SET Owner='" + player.Name + "' WHERE ID='" + IDS + "'" );
ePrivMessage( "You have purchased the vehicle ID [ " + IDS + " ]", player );
DecCash( player , status[ player.ID ].cost )
ePrivMessage("You have selling vehicle ID [ " + IDS + " ]",plr)
IncCash( plr , status[ player.ID ].cost )
status[ player.ID ].cost = null
status[ player.ID ].waiting = false
status[ player.ID ].id = null
status[ player.ID ].name = null
status[ plr.ID ].t = false
ttimeouts.Stop()
}
}
else if ( cmd =="tradecar" )
{
if ( !text ) ePrivMessage("Syntax: /c tradecar <player/id> <cost>",player)
else
{
local veh = player.Vehicle;
local id = player.ID
local plr = FindPlayer( GetTok( text, " ", 1 ) ), cost = GetTok( text, " ", 2 );
if ( !veh ) ePrivMessage( "Error: You must be in a vehicle.", player );
else
{
local q = QuerySQL( db, "SELECT * FROM Cars WHERE rowid LIKE '" + veh.ID + "'" );
if ( plr == null ) ePrivMessage("Invalid Player",player)
else if ( GetSQLColumnData( q, 2 ) != player.Name ) ePrivMessage( "Error: You do not own this vehicle.", player );
else if ( !plr ) ePrivMessage("Error: Invalid player.",player)
else if ( cost == null ) ePrivMessage("Who will set cost ah?",player)
else if ( !IsNum( cost ) ) ePrivMessage( "Error: The cost should be in number.", player );
else
{
status[ player.ID ].t = true
status[ plr.ID ].cost = cost
status[ plr.ID ].waiting = true
status[ plr.ID ].id = veh.ID
status[ plr.ID ].name = player.Name
ePrivMessage("Request send, wait for him reply.",player)
ePrivMessage("Player [ " + player.Name + " ] want sell ID [ " + veh.ID + " ][ " + GetVehicleNameFromModel( veh.Model ) + " ] for $[ " + cost + " ]",plr)
ePrivMessage("Type /c taccept to accept or /c tdeny to reject request",plr)
ttimeouts <- NewTimer("ttimeout",30000,player.ID,1)
}
}
}
}
this is on playerstats
t = false;
cost = 0;
waiting = false;
id = 0;
name = false;
So what's the error message? Do you expect me to guess? Do you think that by giving me that portion of code, I'm just able to test that on my machine?
Man, what the f*k is wrong with you people? Why do I have to waste a couple of posts with you just to get a simple f*ing message of the thrown error.
Well, if you're too lazy to post a simple f*ing error message then I'll also be lazy enough to ignore your stupid question.
Sorry for the outrage bit it's getting ridiculous. Have some god damn respect people. How many times do I have to waste time telling you to be specific.
Too confusing code :-\ and you are trying to sell and person ??? status[plr.ID].cost afaik it should be status[veh.ID].cost
Why are you trying to use my bugged script?
http://pastebin.vc-mp.ga/54f95a3f673f5.html
local 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 .
i set it kratos but error is comparsion between 12000 the money i carry and 1 that the cost of tradecar
Quote from: PsyChO_KiLLeR on Mar 07, 2015, 12:10 PMi set it kratos but error is comparsion between 12000 the money i carry and 1 that the cost of tradecar
Do you even understand your self? I'm just curious, that's all.
whats ur mean?
i know what u feel but i want help on this topic
Quote from: PsyChO_KiLLeR on Mar 07, 2015, 12:27 PMi know what u feel but i want help on this topic
You don't have a brain which understands the term 'help', SLC and other guys here are trying to help a guy without a brain from a long time now....
else if ( player.Cash.tointeger() < cost.tointeger() ) ePrivMessage("Error: You need $ [ " + cost + " ] to buy this vehicle.",player)
Give complete information next time.
You sure you created it? Only a guy with working brain can script.
thanks but now error getting on
else if ( cmd == "taccept" )
{
local cost = status[ player.ID ].cost
local IDS = status[ player.ID ].id
if ( status[ player.ID ].waiting == false ) ePrivMessage("Error: You dont have pending request.",player)
else if ( player.Cash.tointeger() < cost.tointeger() ) ePrivMessage("Error: You need $ [ " + cost + " ] to buy this vehicle.",player)
else
{
Here local plr = FindPlayer( status[ plr.ID ].name )
QuerySQL( db, "UPDATE Cars SET Owner='" + player.Name + "' WHERE ID='" + IDS + "'" );
ePrivMessage( "You have purchased the vehicle ID [ " + IDS + " ]", player );
DecCash( player , status[ player.ID ].cost )
ePrivMessage("You have selling vehicle ID [ " + IDS + " ]",plr)
IncCash( plr , status[ player.ID ].cost )
status[ player.ID ].cost = null
status[ player.ID ].waiting = false
status[ player.ID ].id = null
status[ player.ID ].name = null
status[ plr.ID ].t = false
ttimeouts.Stop()
}
}
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 .
plr isn't defined & you're using him in array index .
cant understand
Quote from: Kratos_ on Mar 07, 2015, 01:46 PMQuote 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.
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?
Quote from: NE.CrystalBlue on Mar 07, 2015, 01:56 PMQuote 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?
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 ] )
Last time I checked, it worked with string also.
http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/FindPlayer
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;
}