SA-MP Forums Archive
Key to check player stats? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Key to check player stats? (/showthread.php?tid=205101)



Key to check player stats? - Rokzlive - 31.12.2010

Ok, i want it so that if a for example you presses the key LCTRL while on foot or 2 in car and is a level 3
pawn Код:
if(playerdata[playerid][level] == 3)
, it checks the nearest player to you within a radius of 10 and sees if they are the hacker team
pawn Код:
playerdata[playerid][team] == 3
, and if they are it charges them the players defined hack charge
pawn Код:
playerdata[playerid][charge]
and gives it to the level 3 player that checked the hacker. Its kinda complex (i think) but id love it if someone would help!

Whoever helps with this will get staff on my SA:MP Computer Wars server.


Re: Key to check player stats? - Hiddos - 31.12.2010

https://sampwiki.blast.hk/wiki/GetPlayerKeys
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange

Should get you quite somewhere. There is however no direct way to check a specific key (Like LCTRL or 'K'), only the special keys which actually do something in-game (Like entering vehicles or shooting guns)


Re: Key to check player stats? - blackwave - 31.12.2010

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new Float:x,Float:y,Float:z;
   
    if(newkeys & KEY_FIRE)
    {
      if(!IsPlayerInAnyVehicle(playerid))
      {
       for(new i = 0; i < MAX_PLAYERS; i++)
       {
           if(IsPlayerConnected(i))
           {
                if(playerdata[i][team] == 3)
                {
                      GetPlayerPos(playerid, x, y, z);
                      if(IsPlayerInRangeOfPoint(i, 10, x, y, z))
                      {
                      new string[128],name[MAX_PLAYER_NAME];
                      GetPlayerName(i,name,sizeof(name));
                      format(string,sizeof(string),"HACKER TEAM: %s\n",name);
                      SendClientMessage(playerid, 0xFF8811FF, string);
                      }
                 }
            }
       }
   }
}
return 1;
}
Gave me fatal errors, but it was due I dont have your variables, like PlayerData. And also I didn't test, just compiled. And without your variables I compiled it normally


Re: Key to check player stats? - Rokzlive - 31.12.2010

It does not have the code to see if the player being check is hacker team tho. Can you revise it by chance?


Re: Key to check player stats? - blackwave - 31.12.2010

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid, x, y, z);
    if(newkeys & KEY_FIRE)
    {
      if(!IsPlayerInAnyVehicle(playerid))
      {
      if(playerdata[i][team] == 3) // Checks if the team is hacker 'here'
      {
       for(new i = 0; i < MAX_PLAYERS; i++)
       {
           if(IsPlayerConnected(i))
           {
                if(playerdata[i][team] == 3)
                {
                     
                      if(IsPlayerInRangeOfPoint(i, 10, x, y, z))
                      {
                      new string[128],name[MAX_PLAYER_NAME];
                      GetPlayerName(i,name,sizeof(name));
                      format(string,sizeof(string),"HACKER TEAM: %s",name);
                      SendClientMessage(playerid, 0xFF8811FF, string);
                      }
                 }
            }
       }
   }
}
}
return 1;
}



Re: Key to check player stats? - cessil - 31.12.2010

blackwave, you should get the playerpos before the loop, less possible functions going off. also \n is pointless with SendClientMessage

edit: also 128 string size is way too big for that message