isplayerinvehicle problem
#1

hello i made /info command , it work good on foot when i enter vehicle that is invalid command

please help me

problem is in

Quote:

if (IsPlayerInVehicle(TargetID,vehicleid))
{
format(vstr, sizeof(vstr), "~w~In ~b~%s",aVehicleNames[modelid - 400]);
}
else
{
vstr = "~w~On Foot";
}

PHP код:
COMMAND:info(playeridparams[])
{
    if (
PlayerInfo[playerid][pSpawned] == 1)
    {
    new 
idx,TargetID,string[512],tmp[256], vstr[512], Locstr[256];
    new 
vehicleid GetPlayerVehicleID(TargetID);
    new 
modelid GetVehicleModel(TargetID);
    
tmp strtok(paramsidx);
    if (!
strlen(tmp))
    {
    
TargetID playerid;
    }
    else
    {
    if (!
isNumeric(tmp))
    {
    
TargetID ReturnUser(tmp);
    if (
TargetID == INVALID_PLAYER_ID)
    {
    return 
1;
    }
    }
    else
    {
    
TargetID strval(tmp);
    if (!
IsPlayerConnected(TargetID))
    {
    
format(stringsizeof(string), "%d Is Not A Valid ID."TargetID);
    
SendClientMessage(playeridCOLOR_ERRORstring);
    return 
1;
    }
    }
    }
    if (
IsPlayerInVehicle(TargetID,vehicleid))
    {
    
format(vstrsizeof(vstr), "~w~In ~b~%s",aVehicleNames[modelid 400]);
    }
    else
    {
    
vstr "~w~On Foot";
    }
    if(
PlayerInfo[TargetID][pSpawned] == 0)
    {
    
Locstr "~r~Dead in Whole Somewhere";
    }else if(
PlayerInfo[TargetID][pSpecID] > -|| AdminDuty[playerid] == 1)
    {
    
Locstr "~p~San Andreas";
    }else{
    
format(Locstrsizeof(Locstr), "~p~%s",PlayerInfo[TargetID][pLocation]);
    }
    
ShowTextDrawMenu(playeridTD_INFOPLAYER,"~g~Player Information"120);
    
format(stringsizeof(string), "~b~%s (%d)~n~~n~~w~Skin ID: ~p~%d~n~~n~~w~Score: ~p~%d ~g~- ~w~Ping: ~p~%d~n~~w~FPS: ~p~%d ~g~- ~w~Packet Loss: ~p~%.2f%~n~~n~~w~Location: ~p~%s~n~%s",PlayerInfo[TargetID][pName], TargetID,GetPlayerSkin(TargetID),GetPlayerScore(TargetID),GetPlayerPing(TargetID),FPS[TargetID], NetStats_PacketLossPercent(playerid),Locstr,vstr);
    
ShowTextDrawMenuItems(playerid0string" "" ",0);
    }else{
    
SendClientMessage(playerid,COLOR_ERROR,"You Cannot Use This Command While You're Dead.");
    }
    return 
1;

Reply
#2

Get the vehicleid and model AFTER you have established who "TargetID" actually is. Using IsPlayerInVehicle seems a bit redundant as well seeing that you can simply check if vehicleid/modelid is greater than zero.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)