Jump to content
  • 0

Problema givegunrange


Edduard

Question

Problema intalnita (descriere):Problema este ca , eu dau /givegunrange 38 si 1 (adica sa dea doar la un metru) si ea da la tot svr
Ero(area / rile) / warning-(ul / urile):
Liniile de cod / sursa / script-ul(obligatoriu):

CMD:givegunrange(playerid, params[])
{
    if(playerVariables[playerid][pAdminLevel] >= 2)
    {
        new gun,sendername[25],string[128],range;
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x,y,z);
        if(sscanf(params, "ii", gun,range)) return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /givegunrange [weapon id] [range]");
        {
            if(gun > 0 && gun < 47)
            {
                    for(new i,g=GetMaxPlayers(); i < g; i ++)
                    {
                        if(IsPlayerConnected(i))
                        {
                            if(IsPlayerInRangeOfPoint(i,range*1000,x,y,z))
                            {
                                GetPlayerName(playerid, sendername, sizeof(sendername));
                                format(string, sizeof(string), "Admin %s has given you gun id %d.", sendername, gun);
                                SendClientMessage(i, COLOR_IN2, string);
                                GivePlayerWeapon(i, gun, 999);
                                Weapon = 1;
                                playerVariables[pJetpack] = 1;
                            }
                        }
                    }
            }
            else return SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: Invalid weapon id.");
        }
    }
    else return SendClientMessage(playerid, COLOR_WHITE, AdminOnly);
      return 1;
}
Imagini / Video (optional):
Ati incercat sa rezolvati singur?: cred ca ar putea fii de aici  if(IsPlayerInRangeOfPoint(i,range*1000,x,y,z)) dar nu stiu sigur  ar trebui sa pun 1

Edited by Edduard

text.gif

SKIPE : EDUARD.SENNOW

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

ProxDetectorS este solutia pentru tine. Am sa-ti las mai jos comanda.  Sper ca ti-am fost de ajutor.

forward ProxDetectorS(Float:radi, playerid, targetid);
public ProxDetectorS(Float:radi, playerid, targetid)
{
    if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
	{
		new Float:posx, Float:posy, Float:posz;
		new Float:oldposx, Float:oldposy, Float:oldposz;
		new Float:tempposx, Float:tempposy, Float:tempposz;
		GetPlayerPos(playerid, oldposx, oldposy, oldposz);
		GetPlayerPos(targetid, posx, posy, posz);
		tempposx = (oldposx -posx);
		tempposy = (oldposy -posy);
		tempposz = (oldposz -posz);
		if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
		{
			return 1;
		}
	}
	return 0;
}

//---------------------- Comanda ------------------------//

CMD:givegunrange(playerid, params[])
{
    new range, gunid;
	if(sscanf(params, "ii", range, gunid)) return SendClientMessage(playerid, -1, "Syntax: /givegunrange [range] [gunid]");
	if(playerVariables[playerid][pAdminLevel] >= 2)
	{
		format(szMessage, sizeof(szMessage), "Administrator %s gave gun %d to everyone in his range.", playerVariables[playerid][pNormalName], gunid);
		foreach(Player, i)
		{
			if(ProxDetectorS(range, playerid, i))
			{
				givePlayerValidWeapon(i, gunid);
				SendClientMessage(i, -1, szMessage);
			}
		}
	}
	return 1;
}

 

  • Upvote 1

j3V8Znq.png

5IGyOAw.png

Link to comment
Share on other sites

  • 0

ProxDetectorS este solutia pentru tine. Am sa-ti las mai jos comanda.  Sper ca ti-am fost de ajutor.

forward ProxDetectorS(Float:radi, playerid, targetid);
public ProxDetectorS(Float:radi, playerid, targetid)
{
    if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
	{
		new Float:posx, Float:posy, Float:posz;
		new Float:oldposx, Float:oldposy, Float:oldposz;
		new Float:tempposx, Float:tempposy, Float:tempposz;
		GetPlayerPos(playerid, oldposx, oldposy, oldposz);
		GetPlayerPos(targetid, posx, posy, posz);
		tempposx = (oldposx -posx);
		tempposy = (oldposy -posy);
		tempposz = (oldposz -posz);
		if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
		{
			return 1;
		}
	}
	return 0;
}

//---------------------- Comanda ------------------------//

CMD:givegunrange(playerid, params[])
{
    new range, gunid;
	if(sscanf(params, "ii", range, gunid)) return SendClientMessage(playerid, -1, "Syntax: /givegunrange [range] [gunid]");
	if(playerVariables[playerid][pAdminLevel] >= 2)
	{
		format(szMessage, sizeof(szMessage), "Administrator %s gave gun %d to everyone in his range.", playerVariables[playerid][pNormalName], gunid);
		foreach(Player, i)
		{
			if(ProxDetectorS(range, playerid, i))
			{
				givePlayerValidWeapon(i, gunid);
				SendClientMessage(i, -1, szMessage);
			}
		}
	}
	return 1;
}

 

Multumesc

Link to comment
Share on other sites

  • 0

ProxDetectorS este solutia pentru tine. Am sa-ti las mai jos comanda.  Sper ca ti-am fost de ajutor.

De ce nu ii lasi sa faca singuri ca sa invete ?

logo.png

ATENTIE!!! Nu imi trimiteti mesaje private care au legatura cu scriptingul. NU mai scriptez.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.