SA-MP Forums Archive
zcmd - 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: zcmd (/showthread.php?tid=385681)



zcmd - Eugene. - 17.10.2012

Hello, if anybody can be so kind to make me these 2 commands into zcmd ? Thank you very much!

Код:
{
    if(strcmp(cmdtext, "/dropgun", true) == 0
	|| strcmp(cmdtext, "/dgun", true) == 0)
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
        new GunID = GetPlayerWeapon(playerid);
        new GunAmmo = GetPlayerAmmo(playerid);
        if(GunID > 0 && GunAmmo != 0)
        {
            new f = MAX_OBJ+1;
            for(new a = 0; a < MAX_OBJ; a++)
            {
                if(dGunData[a][ObjPos][0] == 0.0)
                {
                    f = a;
                    break;
                }
            }
            if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "You can not throw weapons at the moment, try back later!");
			RemovePlayerWeapon(playerid, GunID);
			dGunData[f][ObjData][0] = GunID;
			dGunData[f][ObjData][1] = GunAmmo;
            GetPlayerPos(playerid, dGunData[f][ObjPos][0], dGunData[f][ObjPos][1], dGunData[f][ObjPos][2]);
            dGunData[f][ObjID] = CreateObject(GunObjects[GunID], dGunData[f][ObjPos][0], dGunData[f][ObjPos][1], dGunData[f][ObjPos][2]-1, 93.7, 120.0, 120.0);
            new buffer[50];
			format(buffer, sizeof(buffer), "You threw %s", GunNames[dGunData[f][ObjData][0]]);
			SendClientMessage(playerid, 0x33AA3300, buffer);
        }
        return 1;
    }
    if(strcmp(cmdtext, "/pickupgun", true) == 0
	|| strcmp(cmdtext, "/pgun", true) == 0)
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
        new f = MAX_OBJ+1;
		for(new a = 0; a < MAX_OBJ; a++)
		{
		    if(IsPlayerInRangeOfPoint(playerid, 5.0, dGunData[a][ObjPos][0], dGunData[a][ObjPos][1], dGunData[a][ObjPos][2]))
		    {
		        f = a;
		        break;
		    }
		}
		if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "You are not near the weapon which you can pick up!");
		DestroyObject(dGunData[f][ObjID]);
		GivePlayerWeapon(playerid, dGunData[f][ObjData][0], dGunData[f][ObjData][1]);
		dGunData[f][ObjPos][0] = 0.0;
		dGunData[f][ObjPos][1] = 0.0;
		dGunData[f][ObjPos][2] = 0.0;
		dGunData[f][ObjID] = -1;
		//dGunData[f][ObjData][0] = 0;
		dGunData[f][ObjData][1] = 0;
		new buffer[50];
		format(buffer, sizeof(buffer), "You picked up %s", GunNames[dGunData[f][ObjData][0]]);
  		SendClientMessage(playerid, 0x33AA3300, buffer);
  		return 1;
    }
	return 0;
}



Re: zcmd - Roel - 17.10.2012

pawn Код:
COMMAND:dgun(playerid, params[]) return cmd_dropgun(playerid, params);
    CMD:dropgun(playerid, params[])
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
        new GunID = GetPlayerWeapon(playerid);
        new GunAmmo = GetPlayerAmmo(playerid);
        if(GunID > 0 && GunAmmo != 0)
        {
            new f = MAX_OBJ+1;
            for(new a = 0; a < MAX_OBJ; a++)
            {
                if(dGunData[a][ObjPos][0] == 0.0)
                {
                    f = a;
                    break;
                }
            }
            if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "You can not throw weapons at the moment, try back later!");
            RemovePlayerWeapon(playerid, GunID);
            dGunData[f][ObjData][0] = GunID;
            dGunData[f][ObjData][1] = GunAmmo;
            GetPlayerPos(playerid, dGunData[f][ObjPos][0], dGunData[f][ObjPos][1], dGunData[f][ObjPos][2]);
            dGunData[f][ObjID] = CreateObject(GunObjects[GunID], dGunData[f][ObjPos][0], dGunData[f][ObjPos][1], dGunData[f][ObjPos][2]-1, 93.7, 120.0, 120.0);
            new buffer[50];
            format(buffer, sizeof(buffer), "You threw %s", GunNames[dGunData[f][ObjData][0]]);
            SendClientMessage(playerid, 0x33AA3300, buffer);
        }
        return 1;
    }
    COMMAND:pgun(playerid, params[]) return cmd_pickupgun(playerid, params);
    CMD:pickupgun(playerid, params[])
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
        new f = MAX_OBJ+1;
        for(new a = 0; a < MAX_OBJ; a++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 5.0, dGunData[a][ObjPos][0], dGunData[a][ObjPos][1], dGunData[a][ObjPos][2]))
            {
                f = a;
                break;
            }
        }
        if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "You are not near the weapon which you can pick up!");
        DestroyObject(dGunData[f][ObjID]);
        GivePlayerWeapon(playerid, dGunData[f][ObjData][0], dGunData[f][ObjData][1]);
        dGunData[f][ObjPos][0] = 0.0;
        dGunData[f][ObjPos][1] = 0.0;
        dGunData[f][ObjPos][2] = 0.0;
        dGunData[f][ObjID] = -1;
        //dGunData[f][ObjData][0] = 0;
        dGunData[f][ObjData][1] = 0;
        new buffer[50];
        format(buffer, sizeof(buffer), "You picked up %s", GunNames[dGunData[f][ObjData][0]]);
        SendClientMessage(playerid, 0x33AA3300, buffer);
        return 1;
    }
DON'T put this inside onplayercommand.
But it just somewhere out of it.


Re: zcmd - XtremeR - 17.10.2012

pawn Код:
CMD:dgun(playerid, params[]) return cmd_dropgun(playerid, params);
    CMD:dropgun(playerid, params[])
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
        new GunID = GetPlayerWeapon(playerid);
        new GunAmmo = GetPlayerAmmo(playerid);
        if(GunID > 0 && GunAmmo != 0)
        {
            new f = MAX_OBJ+1;
            for(new a = 0; a < MAX_OBJ; a++)
            {
                if(dGunData[a][ObjPos][0] == 0.0)
                {
                    f = a;
                    break;
                }
            }
            if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "You can not throw weapons at the moment, try back later!");
            RemovePlayerWeapon(playerid, GunID);
            dGunData[f][ObjData][0] = GunID;
            dGunData[f][ObjData][1] = GunAmmo;
            GetPlayerPos(playerid, dGunData[f][ObjPos][0], dGunData[f][ObjPos][1], dGunData[f][ObjPos][2]);
            dGunData[f][ObjID] = CreateObject(GunObjects[GunID], dGunData[f][ObjPos][0], dGunData[f][ObjPos][1], dGunData[f][ObjPos][2]-1, 93.7, 120.0, 120.0);
            new buffer[50];
            format(buffer, sizeof(buffer), "You threw %s", GunNames[dGunData[f][ObjData][0]]);
            SendClientMessage(playerid, 0x33AA3300, buffer);
        }
        return 1;
    }
    CMD:pgun(playerid, params[]) return cmd_pickupgun(playerid, params);
    CMD:pickupgun(playerid, params[])
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
        new f = MAX_OBJ+1;
        for(new a = 0; a < MAX_OBJ; a++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 5.0, dGunData[a][ObjPos][0], dGunData[a][ObjPos][1], dGunData[a][ObjPos][2]))
            {
                f = a;
                break;
            }
        }
        if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "You are not near the weapon which you can pick up!");
        DestroyObject(dGunData[f][ObjID]);
        GivePlayerWeapon(playerid, dGunData[f][ObjData][0], dGunData[f][ObjData][1]);
        dGunData[f][ObjPos][0] = 0.0;
        dGunData[f][ObjPos][1] = 0.0;
        dGunData[f][ObjPos][2] = 0.0;
        dGunData[f][ObjID] = -1;
        //dGunData[f][ObjData][0] = 0;
        dGunData[f][ObjData][1] = 0;
        new buffer[50];
        format(buffer, sizeof(buffer), "You picked up %s", GunNames[dGunData[f][ObjData][0]]);
        SendClientMessage(playerid, 0x33AA3300, buffer);
        return 1;
    }
    return 0;
}
here u go


Re: zcmd - Roel - 17.10.2012

Quote:
Originally Posted by XtremeR
Посмотреть сообщение
pawn Код:
CMD:dgun(playerid, params[]) return cmd_dropgun(playerid, params);
    CMD:dropgun(playerid, params[])
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
        new GunID = GetPlayerWeapon(playerid);
        new GunAmmo = GetPlayerAmmo(playerid);
        if(GunID > 0 && GunAmmo != 0)
        {
            new f = MAX_OBJ+1;
            for(new a = 0; a < MAX_OBJ; a++)
            {
                if(dGunData[a][ObjPos][0] == 0.0)
                {
                    f = a;
                    break;
                }
            }
            if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "You can not throw weapons at the moment, try back later!");
            RemovePlayerWeapon(playerid, GunID);
            dGunData[f][ObjData][0] = GunID;
            dGunData[f][ObjData][1] = GunAmmo;
            GetPlayerPos(playerid, dGunData[f][ObjPos][0], dGunData[f][ObjPos][1], dGunData[f][ObjPos][2]);
            dGunData[f][ObjID] = CreateObject(GunObjects[GunID], dGunData[f][ObjPos][0], dGunData[f][ObjPos][1], dGunData[f][ObjPos][2]-1, 93.7, 120.0, 120.0);
            new buffer[50];
            format(buffer, sizeof(buffer), "You threw %s", GunNames[dGunData[f][ObjData][0]]);
            SendClientMessage(playerid, 0x33AA3300, buffer);
        }
        return 1;
    }
    CMD:pgun(playerid, params[]) return cmd_pickupgun(playerid, params);
    CMD:pickupgun(playerid, params[])
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
        new f = MAX_OBJ+1;
        for(new a = 0; a < MAX_OBJ; a++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 5.0, dGunData[a][ObjPos][0], dGunData[a][ObjPos][1], dGunData[a][ObjPos][2]))
            {
                f = a;
                break;
            }
        }
        if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "You are not near the weapon which you can pick up!");
        DestroyObject(dGunData[f][ObjID]);
        GivePlayerWeapon(playerid, dGunData[f][ObjData][0], dGunData[f][ObjData][1]);
        dGunData[f][ObjPos][0] = 0.0;
        dGunData[f][ObjPos][1] = 0.0;
        dGunData[f][ObjPos][2] = 0.0;
        dGunData[f][ObjID] = -1;
        //dGunData[f][ObjData][0] = 0;
        dGunData[f][ObjData][1] = 0;
        new buffer[50];
        format(buffer, sizeof(buffer), "You picked up %s", GunNames[dGunData[f][ObjData][0]]);
        SendClientMessage(playerid, 0x33AA3300, buffer);
        return 1;
    }
    return 0;
}
here u go
lol nice repeat.


Re: zcmd - XtremeR - 17.10.2012

it aint a repeat, i was writing but u we're bit faster..


Re: zcmd - Roel - 17.10.2012

Ow, well nvm then.


Re: zcmd - Eugene. - 17.10.2012

What do you mean by "DON'T put this inside onplayercommand." ?


Re: zcmd - Roel - 17.10.2012

DCMD commands don't have to be in onplayercommand,
But them outside you the way to create publics.


Re: zcmd - XtremeR - 17.10.2012

he means ZCMD Dont have to be in OnPlayerCommantText


Re: zcmd - Lordzy - 17.10.2012

Why return 0; used in zcmd transfered commands?

Zcmd just needs return 1; , don't need to be added under OnPlayerCommandText callback.