Makehelper
#1

Код:
CMD:makehelper(playerid, params[])
{
    if (Player[playerid][pHelper] >= 4 && Player[playerid][pAdmin] >= 1337) return SendClientMessage(playerid, -1, ADMIN_MESSAGE);

    new para1, level;
    if (sscanf(params, "ri", para1, level)) return SendClientMessage(playerid, -1, "{00E6FF}USAGE:{FFFFFF} /makehelper [IDJucator/ParteDinNume] [level(1-4)]");
    if (para1 == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Invalid player");
    if (!(1 <= level <= 4)) return SendClientMessage(playerid, -1, "Invalid level. It must be between 1 and 4");

    new giveplayer[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME], string[144];

    GetPlayerName(para1, giveplayer, sizeof(giveplayer));
    GetPlayerName(playerid, sendername, sizeof(sendername));

    Player[para1][pHelper] = level;

    printf("AdmWarning: %s has promoted %s to a level %d admin.", sendername, giveplayer, level);
    format(string, sizeof(string), "   You have been promoted to a level %d helper by %s", level, sendername);
    SendClientMessage(para1, COLOR_LIGHTBLUE, string);
    format(string, sizeof(string), "{D11515}[AdmWarning]: {FF9203}%s {FFFFFF}has set {FF9203}%s {FFFFFF}to a level {FF9203}%d {FFFFFF}helper.", sendername, giveplayer, level);
	SendAdminMessage(-1, string);
	return 1;
}
When I type /makehelper nick level it keeps sending me a message with the USAGE message.
Reply
#2

Change
Код:
if (sscanf(params, "ri", para1, level)) return SendClientMessage(playerid, -1, "{00E6FF}USAGE:{FFFFFF} /makehelper [IDJucator/ParteDinNume] [level(1-4)]");
To this:
Код:
if (sscanf(params, "ui", para1, level)) return SendClientMessage(playerid, -1, "{00E6FF}USAGE:{FFFFFF} /makehelper [IDJucator/ParteDinNume] [level(1-4)]");
Reply
#3

Quote:
Originally Posted by zDivine
Посмотреть сообщение
Change
Код:
if (sscanf(params, "ri", para1, level)) return SendClientMessage(playerid, -1, "{00E6FF}USAGE:{FFFFFF} /makehelper [IDJucator/ParteDinNume] [level(1-4)]");
To this:
Код:
if (sscanf(params, "ui", para1, level)) return SendClientMessage(playerid, -1, "{00E6FF}USAGE:{FFFFFF} /makehelper [IDJucator/ParteDinNume] [level(1-4)]");
The problem is not in the specifier. The "u" and "r" specifiers are almost same. The "u" specifier is used for both players and bots, and the "r" specifier is used only for players.
Reply
#4

Quote:
Originally Posted by Darkwood17
Посмотреть сообщение
You should not use return
Actually he should use return, or else the code after that will run, even if he enters a wrong syntax.
What exactly are you entering JXF when you use the command?
Reply
#5

Quote:
Originally Posted by Darkwood17
Посмотреть сообщение
You should not return the message:
Код:
if (sscanf(params, "ri", para1, level)) SendClientMessage(playerid, -1, "{00E6FF}USAGE:{FFFFFF} /makehelper [IDJucator/ParteDinNume] [level(1-4)]");

The "u" and "r" specifiers are almost same. The "u" specifier is used for both players and bots, and the "r" specifier is used only for players.
Wrong. Read Stinged's message.
Reply
#6

I tried to make myself a helper, like this:

/makehelper JXF 4

But I get a message with the SYNTAX back.
Reply
#7

Update sscanf plugin and its include, re-compile and try again. Your code is fine.
Reply
#8

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Update sscanf plugin and its include, re-compile and try again. Your code is fine.
I have done as you said, and now when I type /makehelper it says SERVER: Unknown command.
Reply
#9

Quote:
Originally Posted by Darkwood17
Посмотреть сообщение
I have never returned a value before and never had problems.
But you have used else if for the rest, haven't you? For his current code, not returning a value will continue the rest of the checks which will stop eventually to the level not being between 1-4.

---

Quote:
Originally Posted by JXF
Посмотреть сообщение
Код:
[18:22:45] Script[gamemodes/GM.amx]: Run time error 19: "File or function is not found"
[18:22:45] Number of vehicle models: 1
[18:23:05] [connection] 192.168.0.5:54109 requests connection cookie.
[18:23:06] [connection] incoming connection: 192.168.0.5:54109 id: 0
[18:23:07] [join] JXF has joined the server (0:192.168.0.5)
[18:23:07] AllowPlayerTeleport() : function is deprecated. Please see OnPlayerClickMap()
[18:23:20] RCON (In-Game): Player #0 (JXF) failed login.
[18:23:29] RCON (In-Game): Player #0 (JXF) has logged in.
[18:23:34] Admin JXF made JXF a level 1339 admin.
[18:23:36] Admin JXF made JXF a level 1338 admin.
[18:23:37] Admin JXF made JXF a level 1337 admin.
Console input: gmx
[18:24:12] Script[gamemodes/GM.amx]: Run time error 19: "File or function is not found"
[18:24:12] Number of vehicle models: 0
[18:24:12] AllowPlayerTeleport() : function is deprecated. Please see OnPlayerClickMap()
Console input: gmx
[18:26:50] Script[gamemodes/GM.amx]: Run time error 19: "File or function is not found"
[18:26:50] Number of vehicle models: 0
[18:26:50] AllowPlayerTeleport() : function is deprecated. Please see OnPlayerClickMap()
[18:30:34] RCON (In-Game): Player [JXF] sent command: gm
[18:30:35] RCON (In-Game): Player [JXF] sent command: gmx
[18:30:47] Script[gamemodes/GM.amx]: Run time error 19: "File or function is not found"
[18:30:47] Number of vehicle models: 0
[18:30:47] AllowPlayerTeleport() : function is deprecated. Please see OnPlayerClickMap()
[18:30:55] Admin JXF made JXF a level 1338 admin.
Console input: gmx
[18:36:39] Script[gamemodes/GM.amx]: Run time error 19: "File or function is not found"
[18:36:39] Number of vehicle models: 0
[18:36:39] AllowPlayerTeleport() : function is deprecated. Please see OnPlayerClickMap()
Console input: gmx
[18:38:02] Script[gamemodes/GM.amx]: Run time error 19: "File or function is not found"
[18:38:02] Number of vehicle models: 0
[18:38:02] AllowPlayerTeleport() : function is deprecated. Please see OnPlayerClickMap()
For start, remove "AllowPlayerTeleport" from the script and use: https://sampwiki.blast.hk/wiki/OnPlayerClickMap
Reply
#10

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
But you have used else if for the rest, haven't you? For his current code, not returning a value will continue the rest of the checks which will stop eventually to the level not being between 1-4.

---



For start, remove "AllowPlayerTeleport" from the script and use: https://sampwiki.blast.hk/wiki/OnPlayerClickMap
I am getting extremely confused, as most of my commands in my gamemode now do not work and for example, /makeadmin sends the wrong syntax.

I do not know what is causing this. Here is the gamemode:
Код:
// Basic Gamemode Script made by Axel
// DO NOT REMOVE CREDITS



//Includes
#include <a_samp>
#include <zcmd>
#include <YSI/y_ini>
#include <sscanf2>
#include <crashdetect>

//Defines
#define SCM   SendClientMessage
#define SCMToAll   SendClientMessageToAll
#define pid   playerid
#define SPH   SetPlayerHealth
#define SPSA  SetPlayerSpecialAction
#define STOP_ANIM   "Press the F key to stop the animation"
#define ADMIN_MESSAGE   "You are not allowed to use this command"


//Enum
enum PlayerInfo
{
	pAdmin,
	pHelper
}

//New
new gPlayer_Duty[MAX_PLAYERS];
new Player[MAX_PLAYERS][PlayerInfo];

// Stock

stock SendAdminMessage(const color, const message[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
	{
	    printf("Player %i <pAdmin: %i>", i, Player[i][pAdmin]);
	    if(Player[i][pAdmin] >= 4)
	    {
	        printf("Found player %i, sending message", i);
	        SendClientMessage(i, color, message);
		}
	}
    return 1;
}
//Server Properties
#define SERVER_NAME   "[0.3.7]JXF's server."
#define SERVER_PASSWORD   ""
#define SERVER_VERSION "V1.0"
#define SERVER_RCON   "Parola123"
#define SERVER_MAP   "Your map name here"
#define SERVER_FORUM "Your forum here"
#define weburl   "Your website here"
#define SERVER_TEAMSPEAK "Your teamspeak here"

//Color Defines
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x243DD5
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_RED 0xAA3333AA
#define COLOR_LIME 0x10F441AA
#define COLOR_MAGENTA 0xFF00FFFF
#define COLOR_NAVY 0x000080AA
#define COLOR_AQUA 0xF0F8FFAA
#define COLOR_CRIMSON 0xDC143CAA
#define COLOR_FLBLUE 0x6495EDAA
#define COLOR_BISQUE 0xFFE4C4AA
#define COLOR_BLACK 0x000000AA
#define COLOR_CHARTREUSE 0x7FFF00AA
#define COLOR_BROWN 0XA52A2AAA
#define COLOR_CORAL 0xFF7F50AA
#define COLOR_GOLD 0xB8860BAA
#define COLOR_GREENYELLOW 0xADFF2FAA
#define COLOR_INDIGO 0x4B00B0AA
#define COLOR_IVORY 0xFFFF82AA
#define COLOR_LAWNGREEN 0x7CFC00AA
#define COLOR_SEAGREEN 0x20B2AAAA
#define COLOR_LIMEGREEN 0x32CD32AA
#define COLOR_MIDNIGHTBLUE 0X191970AA
#define COLOR_MAROON 0x800000AA
#define COLOR_OLIVE 0x808000AA
#define COLOR_ORANGERED 0xFF4500AA
#define COLOR_PINK 0xF9AFBC
#define COLOR_SPRINGGREEN 0x00FF7FAA
#define COLOR_TOMATO 0xFF6347AA 
#define COLOR_YELLOWGREEN 0x9ACD32AA 
#define COLOR_MEDIUMAQUA 0x83BFBFAA
#define COLOR_MEDIUMMAGENTA 0x8B008BAA 
#define DIALOG_REGISTER 2000
#define DIALOG_LOGIN 2001
#define WHITE "{FFFFFF}"
#define RED "{F81414}"
#define GREEN "{00FF22}"
#define LIGHTBLUE "{00CED1}"

main()
{
    SendRconCommand("hostname "SERVER_NAME);
    SendRconCommand("rcon_password "SERVER_RCON);
    SendRconCommand("gamemodetext "SERVER_VERSION);
	SendRconCommand("mapname "SERVER_MAP);
	SendRconCommand("weburl "SERVER_FORUM);
	SendRconCommand("password "SERVER_PASSWORD);
	printf(""SERVER_NAME" ("SERVER_VERSION"), has been loaded successfully.");
}



OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:FZ)
{
	return 1;
}

//--------------Commands--------------

CMD:suicide(pid,params[])
{
	SPH(pid, 0);
	SCM(playerid, -1, "You have commited suicide!");
	return 1;
}

CMD:heal(pid,params[])
{
	if(IsPlayerAdmin(pid))
	SPH(pid, 100);
	if(!IsPlayerAdmin(pid))
	SCM(pid, COLOR_RED, ADMIN_MESSAGE);
	return 1;
}

CMD:jetpack(pid,params[])
{
	if(IsPlayerAdmin(pid))
	SetPlayerSpecialAction(pid, 2);
	if(!IsPlayerAdmin(pid))
	SCM(pid, COLOR_RED, ADMIN_MESSAGE);
	return 1;
}

CMD:jpoff(pid,params[])
{
	if(IsPlayerAdmin(pid))
	SetPlayerSpecialAction(pid, 0);
	if(!IsPlayerAdmin(pid))
	SCM(pid, COLOR_RED, ADMIN_MESSAGE);
	return 1;
}

CMD:handsup(pid,params[])
{
	SPSA(pid, 10);
	SCM(pid, COLOR_YELLOW, STOP_ANIM);
	return 1;
}

CMD:pee(pid,params[])
{
	SPSA(pid, 68);
	SCM(pid, COLOR_YELLOW, STOP_ANIM);
	return 1;
}

CMD:ahelp(pid,params[])
{
	if(IsPlayerAdmin(pid))
	SCM(pid, COLOR_YELLOW, "OWNER:/heal, /jetpack, /jpoff");
	if(!IsPlayerAdmin(pid))
	SCM(pid, COLOR_RED, ADMIN_MESSAGE);
	return 1;
}

CMD:animhelp(pid,params[])
{
	SCM(pid, -1, "/handsup, /pee,");
	return 1;
}

CMD:info(playerid, params[]) return cmd_information(playerid, params);
CMD:information(playerid, params[])
{
	SCM(playerid, COLOR_WHITE, "---------------------------------------------------");
	SCM(playerid, COLOR_LIGHTBLUE, ""SERVER_NAME" - Info");
	SCM(playerid, COLOR_WHITE, "Version: "SERVER_VERSION"");
	SCM(playerid, COLOR_WHITE, "Webstie: "SERVER_FORUM"");
	SCM(playerid, COLOR_WHITE, "Teamspeak: "SERVER_TEAMSPEAK"");
	SCM(playerid, COLOR_WHITE, "---------------------------------------------------");
	return 1;
}

CMD:restart(pid,params[])
{
	if(IsPlayerAdmin(playerid))
	SendRconCommand("gmx");
	if(!IsPlayerAdmin(playerid))
	SCM(pid, COLOR_RED, ADMIN_MESSAGE);
	return 1;
}

CMD:gun(pid,params[])
{
	if(IsPlayerAdmin(playerid))
	{
			GivePlayerWeapon(pid, 38, 6000);
			GivePlayerWeapon(pid, 24, 6000);
			GivePlayerWeapon(pid, 4, 1);
			SCM(pid, COLOR_LIGHTBLUE, " You have been granted admin weapons.");
	}
	else SCM(pid, COLOR_RED, ADMIN_MESSAGE);
	return 1;
}


public OnPlayerConnect(playerid)
{
	gPlayer_Duty[playerid] = 0;
	return 1;
}

CMD:aod(pid,params[])
{
	if (Player[playerid][pAdmin] < 1) return SCM(pid, COLOR_RED, ADMIN_MESSAGE);
	
	new aod[65], name[MAX_PLAYER_NAME];
	GetPlayerName(pid, name, MAX_PLAYER_NAME);

	if(!gPlayer_Duty[playerid])
	{
 		SPH(pid, 99999);
		SetPlayerArmour(pid, 100);
	
		format(aod, sizeof aod, "Admin %s is now on duty. Use /report for any assistance.", name);
		SCMToAll(COLOR_LIME, aod);

		gPlayer_Duty[playerid] = 1;
	}
	else
	{
 		SPH(pid, 100);
   		SetPlayerArmour(pid, 0);
		format(aod, sizeof aod, "Admin %s is no longer on duty.", name);
		SCMToAll(COLOR_BLUE, aod);

		gPlayer_Duty[playerid] = 0;
	}
	return 1;
}

CMD:hod(pid, params[])
{
	if (Player[playerid][pHelper] < 1) return SCM(pid, COLOR_RED, ADMIN_MESSAGE);
	
	new hod[65], name[MAX_PLAYER_NAME];
	GetPlayerName(pid, name, MAX_PLAYER_NAME);
	
	if(!gPlayer_Duty[playerid])
	{
	    SPH(pid, 99999);
	    SetPlayerArmour(pid, 100);
	    
	    format(hod, sizeof hod, "Helper %s is now on duty. Use /needhelp for any assistance.", name);
	    SCMToAll(COLOR_LIME, hod);
	    
	    gPlayer_Duty[playerid] = 1;
	}
	else
	{
	    SPH(pid, 100);
		SetPlayerArmour(pid, 0);
		format(hod, sizeof hod, "Helper %s is no longer on duty.", name);
		SCMToAll(COLOR_BLUE, hod);
		
		gPlayer_Duty[playerid] = 0;
	}
	return 1;
}


CMD:troll(pid,params[])
{
	if(!IsPlayerAdmin(playerid))
	SCM(pid, COLOR_RED, "Hehehe, you tried!");
	if(IsPlayerAdmin(playerid))
	SCMToAll(COLOR_LIGHTBLUE, "   You have been promoted to a level 1338 Admin by JXF. Use /ah for help.");
	return 1;
}

//----------------------------------[MAKEADMIN]------------------------------------------------
CMD:makeadmin(playerid, params[])
{
    if (Player[playerid][pAdmin] < 1338) return SendClientMessage(playerid, -1, ADMIN_MESSAGE);

    new para1, level;
    if (sscanf(params, "ri", para1, level)) return SendClientMessage(playerid, -1, "{00E6FF}USAGE:{FFFFFF} /makeadmin [IDJucator/ParteDinNume] [level(1-1338)]");
    if (para1 == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Invalid player");
    if (!(1 <= level <= 1338)) return SendClientMessage(playerid, -1, "Invalid level. It must be between 1 and 1338");

    new giveplayer[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME], string[144];

    GetPlayerName(para1, giveplayer, sizeof(giveplayer));
    GetPlayerName(playerid, sendername, sizeof(sendername));

    Player[para1][pAdmin] = level;

    printf("AdmWarning: %s has promoted %s to a level %d admin.", sendername, giveplayer, level);
    format(string, sizeof(string), "   You have been promoted to a level %d admin by %s", level, sendername);
    SendClientMessage(para1, COLOR_LIGHTBLUE, string);
    format(string, sizeof(string), "{D11515}[AdmWarning]: {FF9203}%s {FFFFFF}has set {FF9203}%s {FFFFFF}to a level {FF9203}%d {FFFFFF}admin.", sendername, giveplayer, level);
	SendAdminMessage(-1, string);
	return 1;
}
//--------------Makehelper--------------
CMD:makehelper(playerid, params[])
{
    if (Player[playerid][pHelper] >= 4 && Player[playerid][pAdmin] >= 1337) return SendClientMessage(playerid, -1, ADMIN_MESSAGE);

    new para1, level;
    if (sscanf(params, "ui", para1, level)) return SendClientMessage(playerid, -1, "{00E6FF}USAGE:{FFFFFF} /makehelper [IDJucator/ParteDinNume] [level(1-4)]");
    if (para1 == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Invalid player");
    if (!(1 <= level <= 4)) return SendClientMessage(playerid, -1, "Invalid level. It must be between 1 and 4");

    new giveplayer[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME], string[144];

    GetPlayerName(para1, giveplayer, sizeof(giveplayer));
    GetPlayerName(playerid, sendername, sizeof(sendername));

    Player[para1][pHelper] = level;

    printf("AdmWarning: %s has promoted %s to a level %d admin.", sendername, giveplayer, level);
    format(string, sizeof(string), "   You have been promoted to a level %d helper by %s", level, sendername);
    SendClientMessage(para1, COLOR_LIGHTBLUE, string);
    format(string, sizeof(string), "{D11515}[AdmWarning]: {FF9203}%s {FFFFFF}has set {FF9203}%s {FFFFFF}to a level {FF9203}%d {FFFFFF}helper.", sendername, giveplayer, level);
	SendAdminMessage(-1, string);
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)