SA-MP Forums Archive
CMD PROBLEM - 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 PROBLEM (/showthread.php?tid=580306)



CMD PROBLEM - sscarface - 04.07.2015

I don't know whats wrong with it. I think it may be sscanf.

PROBLEM: If Player A is typed /i 1 so it shows to information to player A about id 1.
If Player A is watching and if player B typed /i 2 so it shows to both players about id 2.

Solution: It should show to player A about /i 1 and player B to /i 2.

PHP код:
CMD:i(playeridparams[])
{
   new 
targetidstring[300], string3[300], string4[128], name[60];
   if(
sscanf(params"i"targetid)) SendClientMessage(playeridCOLOR_WHITE"USAGE: /i [id]");
   if(
IsPlayerConnected(targetid) == 0SendClientMessage(playeridCOLOR_RED"Player is not connected!");
   else
   {
         
HideDraw(playerid);
          
GetPlayerName(targetidname60);
          new 
veh GetPlayerVehicleID(targetid), Float:Distance GetDistanceBetweenPlayers(playerid,targetid) * 0.000621371192;
         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(targetid), grid;
         
HideDraw(playerid);
         
TextDrawShowForPlayer(playerid,infotext1);
         
TextDrawShowForPlayer(playerid,infotext3);
         
TextDrawShowForPlayer(playerid,infotext4);
         
TextDrawShowForPlayer(playerid,INFOBOX);
         if(!
IsPlayerInAnyVehicle(targetid))
         {
               if(
groupinfo[grid][active])
               {
                   
format(string300"~n~            ~g~Player Info - ~r~~h~%s (%d)~n~                  ~g~Score - ~w~%d ~n~~n~~y~Location - ~w~%s~n~~y~Drive - ~w~On foot~n~~y~Distance - ~w~%0.2f Miles~n~~y~Speed - ~w~%d/mph~n~~y~Altitude - ~w~%s feet~n~~y~Wanted Level - ~w~%d~n~~y~Hit Contract - ~g~$%d"nametargetidGetPlayerScore(targetid), ReturnPlayerZone(targetid), Distance,final_speedGetAltitude(targetid), GetPlayerWantedLevel(targetid), HasHit[targetid]);
                   
format(string3,300,"~n~~n~~y~Group - ~w~%s (%d)",groupinfo[grid][grname], grid);
                   if(
pData[targetid][pVip] ==1)
                   {
                      
format(string4,128,"~n~~n~~n~~b~Donating Player");
                   }
               }
               else if(!
groupinfo[grid][active])
               {
                   
format(string300"~n~            ~g~Player Info - ~r~~h~%s (%d)~n~                  ~g~Score - ~w~%d ~n~~n~~y~Location - ~w~%s~n~~y~Drive - ~w~On foot~n~~y~Distance - ~w~%0.2f Miles~n~~y~Speed - ~w~%d/mph~n~~y~Altitude - ~w~%s feet~n~~y~Wanted Level - ~w~%d~n~~y~Hit Contract - ~g~$%d"nametargetidGetPlayerScore(targetid), ReturnPlayerZone(targetid), Distance,final_speedGetAltitude(targetid), GetPlayerWantedLevel(targetid), HasHit[targetid]);
                   
format(string3,300,"~n~~n~~y~Group - ~w~None");
                   if(
pData[targetid][pVip] ==1)
                   {
                      
format(string4,128,"~n~~n~~n~~b~Donating Player");
                   }
               }
         }else
         if(
IsPlayerInAnyVehicle(targetid))
         {
               if(
groupinfo[grid][active])
               {
                  
format(string300"~n~            ~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 Miles~n~~y~Speed - ~w~%d/mph~n~~y~Altitude - ~w~%s feet~n~~y~Wanted Level - ~w~%d~n~~y~Hit Contract - ~g~$%d",name,targetid,GetPlayerScore(targetid),ReturnPlayerZone(targetid),VehicleNames[GetVehicleModel(carid)-400],Distance,final_speed,GetAltitude(targetid),GetPlayerWantedLevel(targetid),HasHit[targetid]);
                  
format(string3,300,"~n~~n~~y~Group - ~w~%s (%d)",groupinfo[grid][grname], grid);
                  if(
pData[targetid][pVip] ==1)
                  {
                      
format(string4,128,"~n~~n~~n~~b~Donating Player");
                  }
               }
               else if(!
groupinfo[grid][active])
               {
                  
format(string300"~n~            ~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 Miles~n~~y~Speed - ~w~%d/mph~n~~y~Altitude - ~w~%s feet~n~~y~Wanted Level - ~w~%d~n~~y~Hit Contract - ~g~$%d"nametargetidGetPlayerScore(targetid), ReturnPlayerZone(targetid),VehicleNames[GetVehicleModel(carid)-400], Distance,final_speedGetAltitude(targetid), GetPlayerWantedLevel(targetid), HasHit[targetid]);
                  
format(string3,300,"~n~~n~~y~Group - ~w~None");
                  if(
pData[targetid][pVip] ==1)
                  {
                      
format(string4,128,"~n~~n~~n~~b~Donating Player");
                  }
               }
         }
         
TextDrawSetString(infotext1,string);
         
TextDrawSetString(infotext3,string3);
         
TextDrawSetString(infotext4,string4);
   }
   return 
1;

Thanks!


AW: CMD PROBLEM - Mencent - 04.07.2015

Hello!

You should use Player Textdraws because global textdraws are for all users and it shows always the same information.
Please do it and look if it will be work.


- Mencent


Re: CMD PROBLEM - sscarface - 04.07.2015

Could you explain more. How do i put textdraw. Isn't this textdraw im using?

Anyways, Is there any other solution? Thanks!


AW: CMD PROBLEM - Mencent - 04.07.2015

https://sampwiki.blast.hk/wiki/TextDrawCreate is different as https://sampwiki.blast.hk/wiki/CreatePlayerTextDraw

Maybe you can see the difference.