else if ( cmd == "np" )
{
if ( !text ) ClientMessage("/np <pickupid> Np is used to see if you are near the pickup.",player,255,255,0)
else if ( !IsNum( text ) ) ClientMessage("Use numbers!",player,255,255,0)
else
{
local picpi = FindPickup(GetTok( text, " ", 1 ));
if ( picpi )
{
if ( DistanceFromPoint( picpi.Pos.x, picpi.Pos.y , player.Pos.x, player.Pos.y ) < 5 ) {
{
ClientMessage("You're near the pickup.",player,255,255,0)
}
}
else ClientMessage("You're not near the pickup",player,255,255,0)
}
else MessagePlayer("Pickup doesn't exists.",player)
}
}
Error :
[SCRIPT] OnPlayerCommand Error: parameter 1 has an invalid type 'string' ; expected: 'integer'
No line specified in the error.
On which line does it gives the error?
if this line:-
local picpi = FindPickup(GetTok( text, " ", 1 ));
Then change it to
local picpi = FindPickup(text.tointeger())
You used IsNum( text ) that means now the rest of the code will execute only when the given parameter is number/integer. That means you have to use .tointeger() with the text parameter since the original reference to text variable will be string.
Do what Kakan said and it should work however I would advise you not to use GetTok everywhere even where it is not needed.
I also like to note, please remove the try {} catch blocks around your code. It makes debugging a lot easier since it would actually show linenumbers and stack.
Solved, locked and alright
@Thijn .