[Solved] See the other player's weapons (Only tested on my own)
#9

Solved. The
pawn Код:
else(SendClientMessage,playerid,white, "SERVER: ID not connected");
Needs to be removed at all. Also, tmp = strtok(cmdtext,idx); had to be added under OnPlayerCommandText.

I took a look at some other scripts which helped me out a bit.

Finally it works, I tested it on my own. had some bugs but they are fixed now .

The code:
Under OnplayerCommandText:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128];
new idx;
new tmp[128];
cmd = strtok(cmdtext, idx);
The ReturnUser code (scroll up a few posts)
This code is under my forwards.

And the command:
pawn Код:
if(strcmp(cmd, "/pweapons", true) == 0) {
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pweapons [playerid/name]");
new giveplayerid = ReturnUser(tmp);
if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid,red, "Invalid Player ID.");
{
new bullets[12], weapons[12], weapname[12][20];
for(new i = 0; i < 12; i++)
{
GetPlayerWeaponData(giveplayerid, i, weapons[i], bullets[i]);
GetWeaponName(weapons[i], weapname[i], 20);
}
new string[128];
new giveplayername[24];
GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
format(string,sizeof(string),"Weapons of %s.",giveplayername);
SendClientMessage(playerid,red,string);
format(string, sizeof(string),"%s(0) - %s(%d) - %s(%d) - %s(%d) - %s(%d) - %s(%d)",weapname[0],weapname[1],bullets[1],weapname[2],bullets[2],weapname[3],bullets[3],weapname[4],bullets[4],weapname[5],bullets[5]);
SendClientMessage(playerid,COLOR_WHITE,string);
format(string,sizeof(string),"%s(%d) - %s(%d) - %s(%d) - %s(0) - %s(0) - %s(0)",weapname[6],bullets[6],weapname[7],bullets[7],weapname[8],bullets[8],weapname[9],weapname[10],weapname[11]);
SendClientMessage(playerid,COLOR_WHITE,string);
}
return 1;
}
Result:
Код:
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
No picture proof yet.

Thanks all.
- speedruntrainer
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)