How to make a ..
#1

I need a help making a slap and give weapon command.

Example:

* Matej_ slaps [playerid] [reason] around a bit with a large trout.

/giveweapon [playerid] [ammount]

Reply
#2

Copied from ladmin
Код:
	if(strcmp(cmd, "/slap", true) == 0)	{
	if(PlayerInfo[playerid][Level] >= 2) {
	    new tmp[256];
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))	{
		SendClientMessage(playerid, red, "USAGE: /slap [playerid] [reason]");
		return 1;	}
		new player1;
		player1 = strval(tmp);
		if(!IsPlayerConnected(player1) || player1 == INVALID_PLAYER_ID || (PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel]) )	{
		SendClientMessage(playerid,red,"ERROR: Player is not connected or is yourself");
		return 1;	}
		tmp = strtok(cmdtext, idx);

		GetPlayerName(player1, playername, sizeof(playername));		GetPlayerName(playerid, adminname, sizeof(adminname));
		format(string,256,"You have been slapped by Administrator %s %s ",adminname,cmdtext[7]);	SendClientMessage(player1,red,string);
		format(string,256,"You have slapped %s %s ",playername,cmdtext[7]);	SendClientMessage(playerid,blue,string);
        new Float:Health, Float:x, Float:y, Float:z; GetPlayerHealth(player1,Health); SetPlayerHealth(player1,Health-25); GetPlayerPos(player1,x,y,z);	SetPlayerPos(player1,x,y,z+5); PlayerPlaySound(playerid,1190,0.0,0.0,0.0); PlayerPlaySound(player1,1190,0.0,0.0,0.0);
	} else	{
  	SendClientMessage(playerid,red,"ERROR: You need to be level 2 to use this command");   }
	return 1;	}
You mean /giveweapon [playerid] [weaponid] [ammo ammount] for admins?
Or that player who holds the weapon want to give other player his weapon for the ammount of ammo he wants.
Reply
#3

Look into sscanf and zcmd . The both make handling commands with parameters pretty simple.
Reply
#4

I don't want this commands to be for admins.
Can you guys make it for non-admins ?
Reply
#5

With dcmd + scanff

Copyed this from my admin script.

pawn Код:
dcmd_slap(playerid, params[])
{
    new slapid;
    new string[128];
    new reason[128];

    if(sscanf(params, "uz", slapid, reason)) return SendClientMessage(playerid,red,"Error: /slap <playerid/name> Reason.");
    if(!IsPlayerConnected(slapid) || slapid == INVALID_PLAYER_ID || slapid == playerid) return SendClientMessage(playerid,red,"Error: Player is not connected or it is yourself.");
    format(string,sizeof(string),"Admin: %s(id: %d) has slapped %s(id: %d) Reason: %s.",UserUD[playerid][accname],playerid,UserUD[slapid][accname],slapid,reason);
    SendClientMessageToAll(adminaction,string);

    new Float:x,
        Float:y,
        Float:z;
    GetPlayerPos(slapid, x,y,z);
    SetPlayerPos(slapid, x, y, z+8);
    PlayerPlaySound(slapid, 1190, 0,0,0);
    }
    return 1;
}
Reply
#6

You didnt can use search!?
Reply
#7

Quote:
Originally Posted by Seven.
Посмотреть сообщение
With dcmd + scanff

Copyed this from my admin script.

pawn Код:
dcmd_slap(playerid, params[])
{
    new slapid;
    new string[128];
    new reason[128];

    if(sscanf(params, "uz", slapid, reason)) return SendClientMessage(playerid,red,"Error: /slap <playerid/name> Reason.");
    if(!IsPlayerConnected(slapid) || slapid == INVALID_PLAYER_ID || slapid == playerid) return SendClientMessage(playerid,red,"Error: Player is not connected or it is yourself.");
    format(string,sizeof(string),"Admin: %s(id: %d) has slapped %s(id: %d) Reason: %s.",UserUD[playerid][accname],playerid,UserUD[slapid][accname],slapid,reason);
    SendClientMessageToAll(adminaction,string);

    new Float:x,
        Float:y,
        Float:z;
    GetPlayerPos(slapid, x,y,z);
    SetPlayerPos(slapid, x, y, z+8);
    PlayerPlaySound(slapid, 1190, 0,0,0);
    }
    return 1;
}
Thanks ! I'm going to try if it works.
Reply
#8

It doesn't work I just get 6 errors.
Reply
#9

What errors??
Reply
#10

Quote:
Originally Posted by oттo
Посмотреть сообщение
What errors??
I get 2 errors.

pawn Код:
... (165) : error 010: invalid function or declaration

(301) : warning 203: symbol is never used: "dcmd_slap"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)