hello, need help with a command!
#1

hello,
i've made /info command!
Everything is Ok in Command!. but Player State Bugs!
There is a bug that when i do /i [myid] i can see my state that im in vehicle or im onfoot!
but other player is in vehicle or onfoot and when i use /i(nfo) [playerid] there player state bug's and its only showing onfoot.

Command!
PHP код:
dcmd_info(playeridparams[])
{
    new 
string[256], giveplayerid;
    new 
vehicleid GetPlayerVehicleID(playerid);
    new 
modelid GetVehicleModel(vehicleid);
    if(
sscanf(params"u"giveplayerid)) return SendClientMessage(playeridCOLOR_ERROR"USAGE: /info [Playerid]");
    new 
Levelstr[256], Locstr[256], vstr[256];
    if (
PlayerInfo[giveplayerid][pTeam] == TEAM_LAW || PlayerInfo[giveplayerid][pVigilante] == 1)
    {
    
format(Levelstrsizeof(Levelstr), "~b~Level %d Rank: %s",PlayerInfo[giveplayerid][pLevel],PoliceRanks[PlayerInfo[giveplayerid][pRank]]);
    }
    else
    {
    switch (
PlayerInfo[giveplayerid][pWantedLevel])
    {
        case 
0:format(Levelstrsizeof(Levelstr), "~w~Wanted Level %d Innocent Civilian",PlayerInfo[giveplayerid][pWantedLevel]);
        case 
1..5:format(Levelstrsizeof(Levelstr), "~y~Wanted Level %d",PlayerInfo[giveplayerid][pWantedLevel]);
        case 
6..9:format(Levelstrsizeof(Levelstr), "~r~Wanted Level %d",PlayerInfo[giveplayerid][pWantedLevel]);
        case 
10:format(Levelstrsizeof(Levelstr), "~r~Wanted Level %d Most Wanted",PlayerInfo[giveplayerid][pWantedLevel]);
    }
    }
    if (
PlayerInfo[giveplayerid][pSpawn] == 0)
    {
    
Locstr "~r~Dead in Whole Somewhere";
    }
    else if(
PlayerInfo[giveplayerid][pSpecID] > -1)
    {
    
Locstr "~p~San Andreas";
    }
    else
    {
    
format(Locstrsizeof(Locstr), "~p~%s",PlayerInfo[giveplayerid][pLocation]);
    }
    
    if(
IsPlayerInVehicle(giveplayerid,vehicleid))
    {
    
format(vstrsizeof(vstr), "~p~In %s",aVehicleNames[modelid 400]);
    }
    else
    {
    
vstr "~p~On Foot";
    }
    if(
PlayerInfo[giveplayerid][pTeam] == TEAM_LAW)
    {
    
HideAllServerTextDraws(playerid);
    
StopKeyState(playerid);
    
format(stringsizeof(string), "~g~Player Info~n~_~n~_~n~_~n~_~n~_~n~_~n~_~n~_~n~_~n~_");
    
TextDrawSetString(InfoTD0string);
    
format(stringsizeof(string), "Name: ~b~%s (%d)~n~~w~Skill: ~p~%s~n~~n~%s~n~~w~Location: ~n~%s~n~~b~%s~n~%s",
    
PlayerInfo[giveplayerid][pName],
    
giveplayerid,
    
SkillNames[PlayerInfo[giveplayerid][pSkill]],
    
Levelstr,
    
Locstr,
    
DistanceFromPlayerToPlayer(playeridgiveplayerid),
    
vstr);
    
TextDrawSetString(InfoTD1string);
    
format(stringsizeof(string), "Press~y~ LMB~w~ To Close The Box");
    
TextDrawSetString(InfoTD2string);
    
TextDrawShowForPlayer(playeridInfoTD0);
    
TextDrawShowForPlayer(playeridInfoTD1);
    
TextDrawShowForPlayer(playeridInfoTD2);
    
info1[playerid]=1;
    }
    else
    {
    
HideAllServerTextDraws(playerid);
    
StopKeyState(playerid);
    
format(stringsizeof(string), "~g~Player Info~n~_~n~_~n~_~n~_~n~_~n~_~n~_~n~_~n~_~n~_");
    
TextDrawSetString(InfoTD0string);
    
format(stringsizeof(string), "Name: ~p~%s (%d)~n~~w~Skill:~p~ %s~n~~n~%s~n~~w~Location: ~n~%s~n~~b~%s~n~%s",
    
PlayerInfo[giveplayerid][pName],
    
giveplayerid,
    
SkillNames[PlayerInfo[giveplayerid][pSkill]],
    
Levelstr,
    
Locstr,
    
DistanceFromPlayerToPlayer(playeridgiveplayerid),
    
vstr);
    
TextDrawSetString(InfoTD1string);
    
format(stringsizeof(string), "Press~y~ LMB~w~ To Close The Box");
    
TextDrawSetString(InfoTD2string);
    
TextDrawShowForPlayer(playeridInfoTD0);
    
TextDrawShowForPlayer(playeridInfoTD1);
    
TextDrawShowForPlayer(playeridInfoTD2);
    
info1[playerid]=1;
    }
    return 
1;

Reply
#2

pawn Код:
new vehicleid = GetPlayerVehicleID(playerid);
new modelid = GetVehicleModel(vehicleid);
if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_ERROR, "USAGE: /info [Playerid]");
...
if(IsPlayerInVehicle(giveplayerid,vehicleid))
{
    format(vstr, sizeof(vstr), "~p~In %s",aVehicleNames[modelid - 400]);
}
else
{
    vstr = "~p~On Foot";
}
It gets the vehicleid and modelid of the player who typed the command and then it checks if the given player is in the vehicle of the player who typed the command and if not, it says on foot. So remove the 2 lines above sscanf and change to:
pawn Код:
new modelid = GetVehicleModel(GetPlayerVehicleID(giveplayerid));
if(modelid) format(vstr, sizeof(vstr), "~p~In %s",aVehicleNames[modelid - 400]);
else vstr = "~p~On Foot";
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)