Roleplay commands, strcmp.
#1

I don't know how to script in roleplay commands such as /me, /do, and /b. If anybody could help me it would be appreciated.
Reply
#2

First of all download & include sscanf + define these colours -

Код:
#define COLOR_FADE1 0xC2A2DAAA // somekind of purple for /me /do /low etc
#define COLOR_FADE2 0xFFFFFFAA // white for /b and /shout command
Then paste this under OnPlayerCommandText(playerid, cmdtext[])

Код:
if(strcmp(cmdtext,"/me",true)==0)
{
    new textv2[128];
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /me [action]");
	format(textv2, sizeof(textv2), "** %s %s!", NAMEGET(playerid), params);
    ProxDetector(playerid, 5, textv2, COLOR_FADE1,COLOR_FADE1,COLOR_FADE1,COLOR_FADE1,COLOR_FADE1);
	return 1;
}
Код:
if(strcmp(cmdtext,"/do",true)==0)
{
    new textv2[128];
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /do [action]");
	format(textv2, sizeof(textv2), "** %s  ((%s))",  params, NAMEGET(playerid));
     ProxDetector(playerid, 5, textv2, COLOR_FADE1,COLOR_FADE1,COLOR_FADE1,COLOR_FADE1,COLOR_FADE1);
	return 1;
}
And these stocks for the near messages and for getting the player name at the end of your gm/fs -

Код:
stock ProxDetector(playerid, Float:radius, string[], col1, col2, col3, col4, col5)
{
	new Float:x, Float:y, Float:z;
	GetPlayerPos(playerid, x, y, z);
	new Float:ix, Float:iy, Float:iz;
	new Float:cx, Float:cy, Float:cz;
	foreach(Player, i)
	{
	        if(GetPlayerInterior(playerid) == GetPlayerInterior(i) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
	        {
				GetPlayerPos(i, ix, iy, iz);
				cx = (x - ix);
				cy = (y - iy);
				cz = (z - iz);
				if(((cx < radius/16) && (cx > -radius/16)) && ((cy < radius/16) && (cy > -radius/16)) && ((cz < radius/16) && (cz > -radius/16)))
				{
				    SendClientMessage(i, col1, string);
				}
				else if(((cx < radius/8) && (cx > -radius/8)) && ((cy < radius/8) && (cy > -radius/8)) && ((cz < radius/8) && (cz > -radius/8)))
				{
				    SendClientMessage(i, col2, string);
				}
				else if(((cx < radius/4) && (cx > -radius/4)) && ((cy < radius/4) && (cy > -radius/4)) && ((cz < radius/4) && (cz > -radius/4)))
				{
				    SendClientMessage(i, col3, string);
				}
				else if(((cx < radius/2) && (cx > -radius/2)) && ((cy < radius/2) && (cy > -radius/2)) && ((cz < radius/2) && (cz > -radius/2)))
				{
				    SendClientMessage(i, col4, string);
				}
				else if(((cx < radius) && (cx > -radius)) && ((cy < radius) && (cy > -radius)) && ((cz < radius) && (cz > -radius)))
				{
				    SendClientMessage(i, col5, string);
				}
			}
	}
	return 1;
}

stock NAMEGET(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
        if(name[i] == '_') name[i] = ' ';
    }
    return name;
}
You can make the other commands like /low /shout and so on by editing these ones.

Hope I helped you.

If you have problems with including sscanf or you dont want to use it remove this line -

Код:
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /me [action]");
Reply
#3

Quote:

C:\Users\Playtech\Documents\Vidya\server\gamemodes \baysideroleplay.pwn(189) : error 017: undefined symbol "params"
C:\Users\Playtech\Documents\Vidya\server\gamemodes \baysideroleplay.pwn(190) : error 017: undefined symbol "NAMEGET"
C:\Users\Playtech\Documents\Vidya\server\gamemodes \baysideroleplay.pwn(191) : error 017: undefined symbol "ProxDetector"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


3 Errors.

Help?
Reply
#4

I told you mayne..

Код:
stock ProxDetector(playerid, Float:radius, string[], col1, col2, col3, col4, col5)
{
	new Float:x, Float:y, Float:z;
	GetPlayerPos(playerid, x, y, z);
	new Float:ix, Float:iy, Float:iz;
	new Float:cx, Float:cy, Float:cz;
	foreach(Player, i)
	{
	        if(GetPlayerInterior(playerid) == GetPlayerInterior(i) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
	        {
				GetPlayerPos(i, ix, iy, iz);
				cx = (x - ix);
				cy = (y - iy);
				cz = (z - iz);
				if(((cx < radius/16) && (cx > -radius/16)) && ((cy < radius/16) && (cy > -radius/16)) && ((cz < radius/16) && (cz > -radius/16)))
				{
				    SendClientMessage(i, col1, string);
				}
				else if(((cx < radius/8) && (cx > -radius/8)) && ((cy < radius/8) && (cy > -radius/8)) && ((cz < radius/8) && (cz > -radius/8)))
				{
				    SendClientMessage(i, col2, string);
				}
				else if(((cx < radius/4) && (cx > -radius/4)) && ((cy < radius/4) && (cy > -radius/4)) && ((cz < radius/4) && (cz > -radius/4)))
				{
				    SendClientMessage(i, col3, string);
				}
				else if(((cx < radius/2) && (cx > -radius/2)) && ((cy < radius/2) && (cy > -radius/2)) && ((cz < radius/2) && (cz > -radius/2)))
				{
				    SendClientMessage(i, col4, string);
				}
				else if(((cx < radius) && (cx > -radius)) && ((cy < radius) && (cy > -radius)) && ((cz < radius) && (cz > -radius)))
				{
				    SendClientMessage(i, col5, string);
				}
			}
	}
	return 1;
}

stock NAMEGET(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
        if(name[i] == '_') name[i] = ' ';
    }
    return name;
}
put these at the bottom of you GM/FS

and It seems you arent using sscanf, so remove these lines

Код:
if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /me [action]");
Reply
#5

Reply
#6

I would not use STRCMP. I would suggest using ZCMD, DCMD, or Y_CMD, as those are much faster processors, and provide easier methods.


Off-Topic: LULOLZLZOOLZOLZOLZOZLZOZL
Quote:
Originally Posted by Vince
Посмотреть сообщение
Reply
#7

You must be le meme 9gag master, go away.
Reply
#8

Quote:
Originally Posted by Vince
Посмотреть сообщение
That's so getting deleted. xD

OT: my tutorial goes pretty well in-depth
https://sampforum.blast.hk/showthread.php?tid=336052
Reply
#9

Quote:
Originally Posted by Skyrise
Посмотреть сообщение
I would not use STRCMP. I would suggest using ZCMD, DCMD, or Y_CMD, as those are much faster processors, and provide easier methods.


Off-Topic: LULOLZLZOOLZOLZOLZOZLZOZL
Isn't DCMD and strcmp the same way of processing commands?
Reply
#10

Quote:
Originally Posted by Dizzle
Посмотреть сообщение
First of all download & include sscanf + define these colours -

Код:
#define COLOR_FADE1 0xC2A2DAAA // somekind of purple for /me /do /low etc
#define COLOR_FADE2 0xFFFFFFAA // white for /b and /shout command
Then paste this under OnPlayerCommandText(playerid, cmdtext[])



You can make the other commands like /low /shout and so on by editing these ones.

Hope I helped you.

If you have problems with including sscanf or you dont want to use it remove this line -

Код:
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /me [action]");
The code you have provided is total bull and here is why: the params variable does not exist in strcmp nor in OnPlayerCommandText. You need a better command processor (dcmd, zcmd, etc) for that to work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)