commands not works :(
#1

look in second page please
Reply
#2

Try using this one. This one should work with your script. I can't see an error there, Try pasting an error code so I can see it.

Code:
	if(strcmp(cmd, "/fine", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /fine [playerid/PartOfName] [money] <reason>");
				return 1;
			}
			new playa;
			new money;
			playa = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			money = strval(tmp);
			if (PlayerInfo[playerid][pAdmin] >= 2)
			{
			    if(IsPlayerConnected(playa))
			    {
			        if(playa != INVALID_PLAYER_ID)
			        {
				        GetPlayerName(playa, giveplayer, sizeof(giveplayer));

						new length = strlen(cmdtext);
						while ((idx < length) && (cmdtext[idx] <= ' '))
						{
							idx++;
						}
						new offset = idx;
						new result[128];
						while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
						{
							result[idx - offset] = cmdtext[idx];
							idx++;
						}
						result[idx - offset] = EOS;
						if(!strlen(result))
						{
							SafeGivePlayerMoney(playa, - money);
							format(string, 256, "[ADMIN]: %s (%d) has been fined $%d by %s [No Reason Given].", giveplayer, playa,money, sendername);
							SendAdminMessage(COLOR_LIGHTRED,string);
		                    format(string, sizeof(string), "You have Fined $%d to %s (%d), No Reason Given.",money, giveplayer, playa);
		                    SendClientMessage(playerid,COLOR_LIGHTRED ,string);
		                    format(string, sizeof(string), "%s (%d), Has Been Fined $%d by %s, No Reason Given", giveplayer, playa, money, sendername);
		                    SendClientMessageToAll(COLOR_NICERED, string);
							format(string, sizeof(string), "~r~~h~-Admin Fined- ~n~~n~~n~~n~~n~~n~~n~~y~No reason Given ~n~Money: ~g~$%d", money);
							GameTextForPlayer(playa, string, 7000, 3);
							new y, m, d;
							new h,mi,s;
							getdate(y,m,d);
							gettime(h,mi,s);
							format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s Has been fined by %s | Reason: None | Money: $%d |.",d,m,y,h,mi,s,giveplayer,sendername, money);
							PayLog(string);
							AdminLog(string);
							format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] Fined by %s - Reason: None - Money: $%d .",d,m,y,h,mi,s,sendername,money);
							AddPunishment(playa, string);
							return 1;
						}
						SafeGivePlayerMoney(playa, - money);
						format(string, 256, "[ADMIN]: %s (%d) has been fined $%d by %s [Reason: %s].", giveplayer, playa,money, sendername, (result));
						SendAdminMessage(COLOR_LIGHTRED,string);
	                    format(string, sizeof(string), "You have Fined $%d to %s (%d) for: %s .",money, giveplayer, playa, (result));
	                    SendClientMessage(playerid,COLOR_LIGHTRED ,string);
	                    format(string, sizeof(string), "%s (%d), Has Been Fined $%d by %s for: %s", giveplayer, playa, money, sendername, (result));
	                    SendClientMessageToAll(COLOR_NICERED, string);
						format(string, sizeof(string), "~r~~h~-Admin Fined- ~n~~n~~n~~n~~n~~n~~n~~y~Reason: ~w~%s ~n~Money: ~g~$%d",(result), money);
						GameTextForPlayer(playa, string, 7000, 3);
						new y, m, d;
						new h,mi,s;
						getdate(y,m,d);
						gettime(h,mi,s);
						format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s Has been fined by %s | Reason: %s | Money: $%d |.",d,m,y,h,mi,s,giveplayer,sendername,(result),money);
						PayLog(string);
						AdminLog(string);
						format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] Fined by %s - Reason: %s - Money: $%d.",d,m,y,h,mi,s,sendername,(result),money);
						AddPunishment(playa, string);
					}
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "   you are not authorized to use that command!");
			}
		}
		return 1;
	}
Reply
#3

man u saw my commands? i want them but fixed i wont other commands please fix them its not work try put them in ur gamemode and see

EDIT: there no errors its compile good but when u enter server the commands no work
Reply
#4

no one can help?
Reply
#5

No double post.
and you use 'strcmp' that is not very pupolar here,means less helpers.
Have you tried other command proccecors like zcmd,dcmd,ycmd or something else that isn't strcmp ?
Reply
#6

man i dont know how to use them iam biggner how should i learn ?Q@!
Reply
#7

yes you should learn https://sampwiki.blast.hk/wiki/Strcmp
Reply
#8

Perhaps you should be pointing him towards the better option, not the one he's already using...
https://sampwiki.blast.hk/wiki/Zcmd
Reply
#9

should i use with zcmd sscanf?
Reply
#10

Quote:
Originally Posted by SamiHam
View Post
should i use with zcmd sscanf?
yes its better then strcmp
Reply
#11

pawn Code:
CMD:pay(playerid, params[])
{
    new pID, Amount, string[256], string1[256], transmitter[MAX_PLAYER_NAME], receivers[MAX_PLAYER_NAME];
    if(sscanf(params, "ud", pID, Amount)) return SendClientMessage(playerid, COLOR_WHITE, "[CMD]:/pay [PlayerID] [Amount]");
    if(pID == INVALID_PLAYER_ID) SendClientMessage(playerid, red, "[ERROR]:Player not Found or Connected!");
    else
    {
        GetPlayerName(playerid, transmitter, sizeof(transmitter));
        GetPlayerName(pID, receivers, sizeof(receivers));
        format(string, sizeof(string), "* [CMD]: %s has pay you $%d *", transmitter, Amount);
        SendClientMessage(pID, COLOR_WHITE, string);
        format(string1, sizeof(string1), "* [CMD]: You have pay $%d to %s ", Amount, receivers);
        SendClientMessage(playerid, COLOR_WHITE, string1);
        GivePlayerMoney(pID, Amount);
    }
    return 1;
}
for ZCMD .
Reply
#12

okay okay i started use zcmd and sscanf and givemoney problem sloved
now another problem with zcmd and sscanf look in it

Quote:

new reason;
COMMAND:akill(playerid, params[])
{
if (IsPlayerAdmin(playerid))
{
new
toplayerid, //the player we want to give money to
amount;
//extracting player's id and amount from params
if (!sscanf(params, "ii", toplayerid, reason))
{
if (toplayerid != INVALID_PLAYER_ID)
{
new
message[40];
SetPlayerHealth(playerid, 0);
format(message, sizeof(message), "admin killed u reason : %d", amount);
SendClientMessage(toplayerid, 0x00FF00FF, message);
}
else SendClientMessage(playerid, 0xFF0000FF, "that player is not connected");
}
else SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /akill <plaerid> <reason>");
}
else SendClientMessage(playerid, 0xFF0000FF, "only admins can use this command!");
return 1;
}

its okay no compile errors just when i enter server i do /akill 0 blabla"
its send me message "usage : /akill plaerid reason
and if i do "akill 0 0"
its send me message "admin killed u reason : 0"
only if akill 0 0
its working why?
Reply
#13

okay the givemoney problems solve .
k now CMD:akill problems k

do u have this on ur script ?

pawn Code:
enum pInfo
{
    pAdmin
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Reply
#14

Quote:
Originally Posted by SamiHam
View Post
okay okay i started use zcmd and sscanf and givemoney problem sloved
now another problem with zcmd and sscanf look in it

pawn Code:
new reason;
COMMAND:akill(playerid, params[])
{
if (IsPlayerAdmin(playerid))
{
new
toplayerid, //the player we want to give money to
amount;
//extracting player's id and amount from params
if (!sscanf(params, "ii", toplayerid, reason))
{
if (toplayerid != INVALID_PLAYER_ID)
{
new
message[40];
SetPlayerHealth(playerid, 0);
format(message, sizeof(message), "admin killed u reason : %d", amount);
SendClientMessage(toplayerid, 0x00FF00FF, message);
}
else SendClientMessage(playerid, 0xFF0000FF, "that player is not connected");
}
else SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /akill <plaerid> <reason>");
}
else SendClientMessage(playerid, 0xFF0000FF, "only admins can use this command!");
return 1;
}


its okay no compile errors just when i enter server i do /akill 0 blabla"
its send me message "usage : /akill plaerid reason
and if i do "akill 0 0"
its send me message "admin killed u reason : 0"
only if akill 0 0
its working why?
Akill . .

pawn Code:
CMD:akill(playerid, params[])
{
    new pID, aName[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME], Reason[128], string[256];
    if(PlayerInfo[playerid][pAdmin] >= 3)
    if(sscanf(params,"us",pID, Reason)) return SendClientMessage(playerid,COLOR_WHITE,"[CMD]:/akill [PlayerID] [Reason]");
    else if (pID==INVALID_PLAYER_ID)SendClientMessage(playerid,red,"[ERROR]:Player not Found!");
    else
    {
        GetPlayerName(playerid,aName,sizeof(aName));
        GetPlayerName(pID,pName,sizeof(pName));
        format(string, sizeof(string),"* Admin %s has Admin Killed %s (Reason: %s) *",aName, pName, Reason);
        SendClientMessage(playerid,red,string);
        SetPlayerHealth(pID,0);
    }
    else return SendClientMessage(playerid, red, "[ERROR]:You need to be an Admin to Access this Commands!");
    return 1;
}
Reply
#15

devilxz there was "us" for scanaf u= username
s= ??!
Reply
#16

s = Reason

pawn Code:
if(sscanf(params,"us",pID, Reason))
see that ? "us", pID, Reason))
Reply
#17

did here %s = amount??
Quote:

COMMAND: sethealth(playerid, params[])
{
new pID, aName[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME],Amount[128], string[256];
if (IsPlayerAdmin(playerid))
if(sscanf(params,"us",pID, Amount)) return SendClientMessage(playerid,COLOR_WHITE,"[CMD]:/sethealth [PlayerID] [Amount]");
else if (pID==INVALID_PLAYER_ID)SendClientMessage(playerid ,COLOR_BRIGHTRED,"[ERROR]:Player not Found!");
else
{
GetPlayerName(playerid,aName,sizeof(aName));
GetPlayerName(pID,pName,sizeof(pName));
format(string, sizeof(string),"Admin Has Healed You",aName, pName, Amount);
SendClientMessage(playerid,COLOR_BRIGHTRED,string) ;
SetPlayerHealth(pID,%s);
}
else return SendClientMessage(playerid, COLOR_BRIGHTRED, "[ERROR]:You need to be an Admin to Access this Commands!");
return 1;
}

Reply
#18

use %d - for number
%s is for Text ,
Reply
#19

pawn Code:
COMMAND: sethealth(playerid, params[])
{
new pID, aName[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME],Amount[128], string[256];
if (IsPlayerAdmin(playerid))
if(sscanf(params,"us",pID, Amount)) return SendClientMessage(playerid,COLOR_WHITE,"[CMD]:/sethealth [PlayerID] [Amount]");
else if (pID==INVALID_PLAYER_ID)SendClientMessage(playerid ,COLOR_BRIGHTRED,"[ERROR]:Player not Found!");
else
{
GetPlayerName(playerid,aName,sizeof(aName));
GetPlayerName(pID,pName,sizeof(pName));
format(string, sizeof(string),"Admin Has Healed You",aName, pName, Amount);
SendClientMessage(playerid,COLOR_BRIGHTRED,string) ;
SetPlayerHealth(pID,%s);
}
else return SendClientMessage(playerid, COLOR_BRIGHTRED, "[ERROR]:You need to be an Admin to Access this Commands!");
return 1;
}
show me the error's
Reply
#20

1. For /akill
pawn Code:
COMMAND:akill(playerid, params[])
{
    new toplayerid, reason[64], message[128];
    if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "only admins can use this command!");
    if(sscanf(params, "ds[64]", toplayerid, reason)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /akill <plaerid> <reason>");
    if(toplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000FF, "that player is not connected");
    SetPlayerHealth(playerid, 0);
    format(message, sizeof(message), "Admin killed u reason : %s", reason);
    SendClientMessage(toplayerid, 0x00FF00FF, message);
    return 1;
}
2. For /sethealth
pawn Code:
COMMAND:sethealth(playerid, params[])
{
    new pID, amount, aName[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME], string[256];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "[ERROR]:You need to be an Admin to Access this Commands!");
    if(sscanf(params, "dd", pID, Amount)) return SendClientMessage(playerid, COLOR_WHITE, "[CMD]:/sethealth [PlayerID] [Amount]");
    if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid ,COLOR_BRIGHTRED,"[ERROR]:Player not Found!");
    GetPlayerName(playerid, aName, sizeof(aName));
    GetPlayerName(pID, pName, sizeof(pName));
    //format(string, sizeof(string),"Admin Has Healed You", aName, pName, Amount); //You can do this with SendClientMessage, aName, pName, Amount will be useless.
    format(string, sizeof(string),"Admin %s Has Set %s's Health to %d", aName, pName, Amount); //Admin "playerid" has set "pID" Health to "Amount"
    SendClientMessage(playerid, COLOR_BRIGHTRED, string); //Sends the message to playerid who uses the command
    SendClientMessage(pID, COLOR_BRIGHTRED, string); //Sends the message to target playerid (aka pID)
    SetPlayerHealth(pID, Amount); //Sets pID health to Amount
    return 1;
}
- On SetPlayerHealth, you don't need %s to set the playerhealth. the %s already stored in "Amount"
- %s is for string, %d or %i is for integer.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)