SA-MP Forums Archive
CMD - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: CMD (/showthread.php?tid=578874)



CMD - STONEGOLD - 22.06.2015

What's wrong with it. It doesn't show me textdraw when i am on foot but it does show me when i am in car.

PHP код:
CMD:i(playeridparams[])
{
   new 
IDstring[900], string2[256], string3[900], name[100];
   if(
sscanf(params"i"ID)) SendClientMessage(playeridCOLOR_WHITE"USAGE: /i [id]");
   else if(
IsPlayerConnected(ID) == 0SendClientMessage(playeridCOLOR_RED"Player is not connected!");
   else
   {
         
HideDraw(playerid);
          
GetPlayerName(IDname100);
          
          new 
veh GetPlayerVehicleID(playerid);
          new 
Float:Distance GetDistanceBetweenPlayers(playerid,ID);
         new 
Float:speed_xFloat:speed_yFloat:speed_zFloat:temp_speedfinal_speed;
         
GetVehicleVelocity(vehspeed_x,speed_yspeed_z);
         
temp_speed floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z)) * 136.666667;
         
final_speed floatround(temp_speedfloatround_round);
            
         new 
carid GetPlayerVehicleID(ID);
         
TextDrawShowForPlayer(playerid,infotext3);
         
TextDrawShowForPlayer(playerid,infotext1);
         
TextDrawShowForPlayer(playerid,INFOBOX);
         if(
gTeam[playerid] == CIVILIANS)
         {
             if(!
IsPlayerInAnyVehicle(ID))
             {
                  
format(string900"            ~g~Player Info - ~r~~h~%s (%d)~n~                  ~g~Score - ~w~%d ~n~~n~~y~Location: ~w~%s~n~~y~Drive: ~w~%s~n~~y~Distance: ~w~%0.2f~n~~y~Speed: ~w~%d/mph~n~~y~Altitude: ~w~%s feet~n~~y~Wanted Level: ~w~%d"nameIDGetPlayerScore(playerid), ReturnPlayerZone(ID),VehicleNames[GetVehicleModel(carid)-400],Distance,final_speedGetAltitude(playerid), GetPlayerWantedLevel(ID));
                  
format(string3,900,"~y~Team: ~w~Civilian~n~~y~Hit Contract: ~g~$%d~n~~y~Group:"HasHit[ID]);
             }
             if(
IsPlayerInAnyVehicle(ID))
             {
                  
format(string900"            ~g~Player Info - ~r~~h~%s (%d)~n~                  ~g~Score - ~w~%d ~n~~n~~y~Location: ~w~%s~n~~y~Drive: ~w~%s~n~~y~Distance: ~w~%0.2f~n~~y~Speed: ~w~%d/mph~n~~y~Altitude: ~w~%s feet~n~~y~Wanted Level: ~w~%d"nameIDGetPlayerScore(playerid), ReturnPlayerZone(ID),VehicleNames[GetVehicleModel(carid)-400],Distance,final_speedGetAltitude(playerid), GetPlayerWantedLevel(ID));
                  
format(string3,900,"~y~Team: ~w~Civilian~n~~y~Hit Contract: ~g~$%d~n~~y~Group:"HasHit[ID]);
             }
             
TextDrawSetString(infotext1,string);
             
TextDrawSetString(infotext3,string3);
             
format(string2,256,"~n~~n~~n~~n~~n~~n~~n~~w~Type ~r~~h~LMB ~w~For Hide Thes~n~~w~Boxes!");
             
TextDrawSetString(infotext2,string2);
         } 



Re: CMD - rappy93 - 22.06.2015

Try this.

pawn Код:
CMD:i(playerid, params[])
{
   new ID, string[900], string2[256], string3[900], name[100];
   if(sscanf(params, "i", ID)) SendClientMessage(playerid, COLOR_WHITE, "USAGE: /i [id]");
   if(IsPlayerConnected(ID) == 0)
   {
        SendClientMessage(playerid, COLOR_RED, "Player is not connected!");
   }
   else
   {
        HideDraw(playerid);
        GetPlayerName(ID, name, 100);
           
        new veh = GetPlayerVehicleID(playerid);
        new Float:Distance = GetDistanceBetweenPlayers(playerid,ID);

        new Float:speed_x, Float:speed_y, Float:speed_z, Float:temp_speed, final_speed;
        GetVehicleVelocity(veh, speed_x,speed_y, speed_z);
        temp_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z)) * 136.666667;
        final_speed = floatround(temp_speed, floatround_round);
         
        new carid = GetPlayerVehicleID(ID);

        TextDrawShowForPlayer(playerid,infotext3);
        TextDrawShowForPlayer(playerid,infotext1);
        TextDrawShowForPlayer(playerid,INFOBOX);
        if(gTeam[playerid] == CIVILIANS)
        {
            if(!IsPlayerInAnyVehicle(ID))
            {
                format(string, 900, "            ~g~Player Info - ~r~~h~%s (%d)~n~                  ~g~Score - ~w~%d ~n~~n~~y~Location: ~w~%s~n~~y~Drive: ~w~%s~n~~y~Distance: ~w~%0.2f~n~~y~Speed: ~w~%d/mph~n~~y~Altitude: ~w~%s feet~n~~y~Wanted Level: ~w~%d", name, ID, GetPlayerScore(playerid), ReturnPlayerZone(ID),VehicleNames[GetVehicleModel(carid)-400],Distance,final_speed, GetAltitude(playerid), GetPlayerWantedLevel(ID));
                format(string3,900,"~y~Team: ~w~Civilian~n~~y~Hit Contract: ~g~$%d~n~~y~Group:", HasHit[ID]);
            }
            else
            {
                format(string, 900, "            ~g~Player Info - ~r~~h~%s (%d)~n~                  ~g~Score - ~w~%d ~n~~n~~y~Location: ~w~%s~n~~y~Drive: ~w~%s~n~~y~Distance: ~w~%0.2f~n~~y~Speed: ~w~%d/mph~n~~y~Altitude: ~w~%s feet~n~~y~Wanted Level: ~w~%d", name, ID, GetPlayerScore(playerid), ReturnPlayerZone(ID),VehicleNames[GetVehicleModel(carid)-400],Distance,final_speed, GetAltitude(playerid), GetPlayerWantedLevel(ID));
                format(string3,900,"~y~Team: ~w~Civilian~n~~y~Hit Contract: ~g~$%d~n~~y~Group:", HasHit[ID]);
            }
            TextDrawSetString(infotext1,string);
            TextDrawSetString(infotext3,string3);
            format(string2,256,"~n~~n~~n~~n~~n~~n~~n~~w~Type ~r~~h~LMB ~w~For Hide Thes~n~~w~Boxes!");
            TextDrawSetString(infotext2,string2);
        }
   }
}



Re: CMD - STONEGOLD - 22.06.2015

What did you change? May i know. I don't want copy-paste lol.

EDIT: didn't work


Re: CMD - rappy93 - 22.06.2015

I changed some of the statements. You had a couple else if's that shouldn't have been there and then you had two if's instead of an if and else.


Re: CMD - STONEGOLD - 22.06.2015

Well, It didn't work


AW: CMD - Mencent - 22.06.2015

Hello!


Try this version, please.
PHP код:
CMD:i(playerid,params[])
{
    new 
ID,string[900],string2[256],string3[900],name[MAX_PLAYER_NAME];
    if(
sscanf(params,"i",ID))return SendClientMessage(playerid,COLOR_WHITE,"USAGE: /i [ID]");
    if(!
IsPlayerConnected(ID))return SendClientMessage(playerid,COLOR_RED,"Player is not connected!");
    
HideDraw(playerid);
    
GetPlayerName(ID,name,MAX_PLAYER_NAME);
    new 
veh GetPlayerVehicleID(playerid),Float:Distance GetDistanceBetweenPlayers(playerid,ID);
    new 
Float:speed_x,Float:speed_y,Float:speed_z,Float:temp_speed,final_speed;
    
GetVehicleVelocity(veh,speed_x,speed_y,speed_z);
    
temp_speed floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z)) * 136.666667;
    
final_speed floatround(temp_speed,floatround_round);
    new 
carid GetPlayerVehicleID(ID);
    
TextDrawShowForPlayer(playerid,infotext3);
     
TextDrawShowForPlayer(playerid,infotext1);
     
TextDrawShowForPlayer(playerid,INFOBOX);
     if(
gTeam[playerid] == CIVILIANS)
     {
         if(
GetPlayerState(ID) == PLAYER_STATE_ONFOOT)
         {
             
format(string900"            ~g~Player Info - ~r~~h~%s (%d)~n~                  ~g~Score - ~w~%d ~n~~n~~y~Location: ~w~%s~n~~y~Drive: ~w~%s~n~~y~Distance: ~w~%0.2f~n~~y~Speed: ~w~%d/mph~n~~y~Altitude: ~w~%s feet~n~~y~Wanted Level: ~w~%d"nameIDGetPlayerScore(playerid), ReturnPlayerZone(ID),VehicleNames[GetVehicleModel(carid)-400],Distance,final_speedGetAltitude(playerid), GetPlayerWantedLevel(ID));
              
format(string3,900,"~y~Team: ~w~Civilian~n~~y~Hit Contract: ~g~$%d~n~~y~Group:"HasHit[ID]);
         }
         else if(
GetPlayerState(ID) == PLAYER_STATE_DRIVER || GetPlayerState(ID) == PLAYER_STATE_PASSENGER)
         {
             
format(string900"            ~g~Player Info - ~r~~h~%s (%d)~n~                  ~g~Score - ~w~%d ~n~~n~~y~Location: ~w~%s~n~~y~Drive: ~w~%s~n~~y~Distance: ~w~%0.2f~n~~y~Speed: ~w~%d/mph~n~~y~Altitude: ~w~%s feet~n~~y~Wanted Level: ~w~%d"nameIDGetPlayerScore(playerid), ReturnPlayerZone(ID),VehicleNames[GetVehicleModel(carid)-400],Distance,final_speedGetAltitude(playerid), GetPlayerWantedLevel(ID));
              
format(string3,900,"~y~Team: ~w~Civilian~n~~y~Hit Contract: ~g~$%d~n~~y~Group:"HasHit[ID]);
         }
         
TextDrawSetString(infotext1,string);
          
TextDrawSetString(infotext3,string3);
          
format(string2,256,"~n~~n~~n~~n~~n~~n~~n~~w~Type ~r~~h~LMB ~w~For Hide Thes~n~~w~Boxes!");
          
TextDrawSetString(infotext2,string2);
     }
     return 
1;


- Mencent