[HELP NEEDED]2 RP commands
#1

_________________________________________________

1st problem.

_________________________________________________

/attempt (command)

It shows "attempt: attempted to (action here) and failed / succeeded"

Should show: "Firstname_Lastname: attempted to (action here) and failed / succeeded"

Code:

Код:
//-------------------------[Attempt]--------------------------------------------
	if(strcmp(cmd, "/attempt", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' '))
			{
				idx++;
			}
			new offset = idx;
			new result[64];
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
			{
				result[idx - offset] = cmdtext[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result))
			{
				SendClientMessage(playerid, COLOR_WHITE, "USAGE: /attempt <action>");
				return 1;
			}
			new succeed = 1 + random(2);
			if(succeed == 1)
			{
				format(string, sizeof(string), "%s: attempted to %s and succeeded", GetPlayerName(playerid, sendername, sizeof(sendername)), result);
				ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
			}
			else if(succeed == 2)
			{
				format(string, sizeof(string), "%s: attempted to %s and failed", GetPlayerName(playerid, sendername, sizeof(sendername)), result);
				ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
			}
		}
		return 1;
	}
_________________________________________________


2nd problem


_________________________________________________

idea: If you are in the government service (service id is 13) (a bodyguard) You go to a certain place and do /locker , which gives you several guns.

Errors:
Код:
C:\Documents and Settings\Suns\Desktop\SRPNEW.pwn(4902) : error 010: invalid function or declaration
C:\Documents and Settings\Suns\Desktop\SRPNEW.pwn(4904) : error 010: invalid function or declaration
C:\Documents and Settings\Suns\Desktop\SRPNEW.pwn(4906) : error 010: invalid function or declaration
C:\Documents and Settings\Suns\Desktop\SRPNEW.pwn(4912) : error 021: symbol already defined: "GivePlayerWeapon"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.

Line codes:

(4902):
Код:
if(strcmp(cmdtext, "/locker", true) == 0)
(4904):
Код:
	if(IsPlayerConnected[playerid])
(4906):
Код:
	if(PlayerInfo[playerid][pService] == 13 && PlayerToPoint(30, playerid, position.here,position.here,position.here))
(4912):
Код:
GivePlayerWeapon(playerid, 34, 10000);
Full code:
Код:
if(strcmp(cmdtext, "/locker", true) == 0)
{
	if(IsPlayerConnected[playerid])
	{
	if(PlayerInfo[playerid][pService] == 13 && PlayerToPoint(30, playerid, position.here,position.here,position.here))
{
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s takes duty guns from his locker.", sendername);
ProxDetector(10.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);

GivePlayerWeapon(playerid, 34, 10000);
GivePlayerWeapon(playerid, 29, 10000);
GivePlayerWeapon(playerid, 27, 10000);
GivePlayerWeapon(playerid, 23, 10000);
GivePlayerWeapon(playerid, 41, 10000);
GivePlayerWeapon(playerid, 1, 1);
SetPlayerArmour(playerid, 100);
tazer[playerid] = 2;
			SendClientMessage(playerid,COLOR_PURPLE,"You are now [ON] duty as a Body Guard.");
}


Hopefully I will get helped.
Reply
#2

try
pawn Код:
if(strcmp(cmdtext, "/locker", true) == 0)
{
    if(IsPlayerConnected[playerid])
    {
    if(PlayerInfo[playerid][pService] == 13 && PlayerToPoint(30, playerid, position.here,position.here,position.here))
{
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s takes duty guns from his locker.", sendername);
ProxDetector(10.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);

GivePlayerWeapon(playerid, 34, 10000);
GivePlayerWeapon(playerid, 29, 10000);
GivePlayerWeapon(playerid, 27, 10000);
GivePlayerWeapon(playerid, 23, 10000);
GivePlayerWeapon(playerid, 41, 10000);
GivePlayerWeapon(playerid, 1, 1);
SetPlayerArmour(playerid, 100);
tazer[playerid] = 2;
            SendClientMessage(playerid,COLOR_PURPLE,"You are now [ON] duty as a Body Guard.");
}
}
}
Reply
#3

Attempt:
Код:
if(strcmp(cmd, "/try", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
	    if(gPlayerLogged[playerid] == 0)
	    {
	      SendClientMessage(playerid, COLOR_GREY, "  You havent logged in yet !");
	      return 1;
	    }
			GetPlayerName(playerid, sendername, sizeof(sendername));
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' '))
			{
				idx++;
			}
			new offset = idx;
			new result[64];
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
			{
				result[idx - offset] = cmdtext[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /try [action]");
				return 1;
			}
			new randa = random(2)+1;
			if(PlayerInfo[playerid][pMaskuse] == 1)
			{
				if(randa == 1) format(string, sizeof(string), "*** Stranger tries %s and succeeds", result);
				else format(string, sizeof(string), "*** Stranger tries %s, but fails", result);
			}
			else
			{
			  if(randa == 1) format(string, sizeof(string), "*** %s tries %s and succeeds", sendername, result);
				else format(string, sizeof(string), "*** %s tries %s, but fails", sendername, result);
			}
			ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
			printf("%s", string);
		}
		return 1;
	}
Reply
#4

Quote:
Originally Posted by DarkPower
try
pawn Код:
if(strcmp(cmdtext, "/locker", true) == 0)
{
    if(IsPlayerConnected[playerid])
    {
    if(PlayerInfo[playerid][pService] == 13 && PlayerToPoint(30, playerid, position.here,position.here,position.here))
{
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s takes duty guns from his locker.", sendername);
ProxDetector(10.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);

GivePlayerWeapon(playerid, 34, 10000);
GivePlayerWeapon(playerid, 29, 10000);
GivePlayerWeapon(playerid, 27, 10000);
GivePlayerWeapon(playerid, 23, 10000);
GivePlayerWeapon(playerid, 41, 10000);
GivePlayerWeapon(playerid, 1, 1);
SetPlayerArmour(playerid, 100);
tazer[playerid] = 2;
            SendClientMessage(playerid,COLOR_PURPLE,"You are now [ON] duty as a Body Guard.");
}
}
}
same errors :/
Reply
#5

BUMP. Can anyone please help? Rly need the /locker cmd
Reply
#6

Quote:
Originally Posted by BrianJJ
BUMP. Can anyone please help? Rly need the /locker cmd
if(PlayerInfo[playerid][pService] == 13 && PlayerToPoint(30, playerid, position.here,position.here,position.here))

position here needs to be changed to x,y,z

pawn Код:
if(strcmp(cmdtext, "/locker", true) == 0)
{
    if(PlayerInfo[playerid][pService] == 13 && PlayerToPoint(30, playerid, 2304.9692,-16.1551,26.7422))
{
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s takes duty guns from his locker.", sendername);
ProxDetector(10.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
GivePlayerWeapon(playerid, 34, 10000);
GivePlayerWeapon(playerid, 29, 10000);
GivePlayerWeapon(playerid, 27, 10000);
GivePlayerWeapon(playerid, 23, 10000);
GivePlayerWeapon(playerid, 41, 10000);
GivePlayerWeapon(playerid, 1, 1);
SetPlayerArmour(playerid, 100);
tazer[playerid] = 2;
SendClientMessage(playerid,COLOR_PURPLE,"You are now [ON] duty as a Body Guard.");
}
return 1;
}
It should work now.

Just change the co-ords i put in with you're own.
Reply
#7

Still, doesnt work
Reply
#8

another BUMP
Reply
#9

Ok now, I fixed some errors. Here is what it looks like now, But I still get the errors.

*NOTE: THE LINES THAT HAVE THE ERORRS WILL BE IN BOLD

_________________________________________________

if(strcmp(cmd, "/locker", true) == 0)
{
if((PlayerInfo[playerid][pService] != 13)
{
SendClientMessage(playerid, COLOR_YELLOW, "ERROR: Bodyguards only");
}
GivePlayerWeapon(playerid, 34, 10000);
GivePlayerWeapon(playerid, 29, 10000);
GivePlayerWeapon(playerid, 27, 10000);
GivePlayerWeapon(playerid, 23, 10000);
GivePlayerWeapon(playerid, 41, 10000);
GivePlayerWeapon(playerid, 1, 1);
SetPlayerArmour(playerid, 100);
tazer[playerid] = 2;
SendClientMessage(playerid,COLOR_PURPLE,"You are now [ON] duty as a Body Guard.");
}
}

_________________________________________________


And the error I get is:

error 010: invalid function or declaration

What I first noticed, was, that the both error lines have "if" , what could be the problem?
Reply
#10

pawn Код:
if(strcmp(cmd, "/locker", true) == 0)
{
if((/*<- double bracket here! delete one!*/PlayerInfo[playerid][pService] != 13)
{
SendClientMessage(playerid, COLOR_YELLOW, "ERROR: Bodyguards only");
}
GivePlayerWeapon(playerid, 34, 10000);
GivePlayerWeapon(playerid, 29, 10000);
GivePlayerWeapon(playerid, 27, 10000);
GivePlayerWeapon(playerid, 23, 10000);
GivePlayerWeapon(playerid, 41, 10000);
GivePlayerWeapon(playerid, 1, 1);
SetPlayerArmour(playerid, 100);
tazer[playerid] = 2;
SendClientMessage(playerid,COLOR_PURPLE,"You are now [ON] duty as a Body Guard.");
}
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)