Radius. (WARNING) -
Sasoft - 30.12.2011
Hello, i'm trying to make a command where i'm able to give a skin to people in a radius.
I currently have this but it doesen't work. Could anyone tell me what i'm doing wrong.
pawn Код:
CMD:setskins(playerid, params[])
{
if (PlayerInfo[playerid][pAdmin] >= 3)
{
new string[128], radius, skin;
if(sscanf(params, "dd", skin, radius))
{
SendClientMessageEx(playerid, COLOR_GRAD6, "[Syntax]: /setskins [skin] [radius]");
return 1;
}
if(!IsInvalidSkin(skin))
{
SendClientMessageEx(playerid, COLOR_GREY, "Invalid skin ID!");
return 1;
}
if(radius < 1 || radius > 50)
{
SendClientMessageEx(playerid, COLOR_WHITE, "Radius must be higher than 0 and lower than 51!");
return 1;
}
SetPlayerSkin(playerid, skin, radius);
format(string, sizeof(string), "You have given everyone skin %d in %d radius", skin, radius);
SendClientMessageEx(playerid, COLOR_LIGHTGREEN, string);
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
}
return 1;
}
Warning:
pawn Код:
C:\Users\Bart\Downloads\0.3D\0.3D\gamemodes\syrp.pwn(58482) : warning 202: number of arguments does not match definition
LINE: 58482
pawn Код:
SetPlayerSkin(playerid, skin, radius);
Re: Radius. (WARNING) - T0pAz - 30.12.2011
playerid is only
a player's id. Use for loop to check all the players and make an if statement using IsPlayerInRangeOfPoint to detect if the player is in radius. And also SetPlayerSkin takes 2 argument which is playerid and skin id.
Re: Radius. (WARNING) -
silvan - 30.12.2011
use a for loop here is an example
pawn Код:
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid,x,y,z);
for (new i=0; i < MAX_PLAYERS, i++)
{
if(IsPlayerInRangeOfPoint(i,radius,x,y,z))
{
SetPlayerSkin(i,skin);
}
}
This should work, + Rep me please if it does.
Re: Radius. (WARNING) -
FTLOG - 30.12.2011
Radius shoud be float to. When you do
do
.
EDIT: And replace the second integer "d" in sscanf line with float "f"
Re: Radius. (WARNING) -
Sasoft - 30.12.2011
Alright thanks, so this will work?
pawn Код:
CMD:setskins(playerid, params[])
{
if (PlayerInfo[playerid][pAdmin] >= 3)
{
new string[128], skin, Float:radius;
if(sscanf(params, "df", skin, radius))
{
SendClientMessageEx(playerid, COLOR_GRAD6, "[Syntax]: /setskins [skin] [radius]");
return 1;
}
if(!IsInvalidSkin(skin))
{
SendClientMessageEx(playerid, COLOR_GREY, "Invalid skin ID!");
return 1;
}
if(radius < 1 || radius > 50)
{
SendClientMessageEx(playerid, COLOR_WHITE, "Radius must be higher than 0 and lower than 51!");
return 1;
}
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid,X, Y, Z);
for (new i=0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, radius, X, Y, Z))
{
SetPlayerSkin(i,skin);
}
}
format(string, sizeof(string), "You have given everyone skin %d in %d radius", skin, radius);
SendClientMessageEx(playerid, COLOR_LIGHTGREEN, string);
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
}
return 1;
}
Re: Radius. (WARNING) -
Elmin - 30.12.2011
Код:
forward GetPlayerDistanceToPointEx(playerid,Float:x,Float:y,Float:z);
forward IsPlayerInSphere(playerid,Float:x,Float:y,Float:z,radius);
public GetPlayerDistanceToPointEx(playerid,Float:x,Float:y,Float:z)
{
new Float:x1,Float:y1,Float:z1;
new Float:tmpdis;
GetPlayerPos(playerid,x1,y1,z1);
tmpdis = floatsqroot(floatpower(floatabs(floatsub(x,x1)),2)+floatpower(floatabs(floatsub(y,y1)),2)+floatpower(floatabs(floatsub(z,z1)),2));
return floatround(tmpdis);
}
public IsPlayerInSphere(playerid,Float:x,Float:y,Float:z,radius)
{
if(GetPlayerDistanceToPointEx(playerid,x,y,z) < radius){
return 1;
}
return 0;
}
Код:
//add to your command
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid,X, Y, Z)
for (new i=0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInSphere(i,X, Y, Z, radius))
{
SetPlayerSkin(i,skin);
}
}
i hope that this will help ^^'