CMD:back
#1

I made /afk and /back cmd and it give error

PHP код:
CMD:back(playerid,params[])
{
new 
string[133];
format(string,sizeof(string),"** [{FF0000}%s]{FF00FF} Is Back",pName(playerid));
SendClientMessageToAll(playerid,string);
TogglePlayerControllable(playerid,1);
}
else
{
SendClientMessage(playerid,-1,"You Not Afk");
}
return 
1;

Give ME Errors:

Код:
D:\samp folder\XtremeX-Stunting\gamemodes\XtremeX-Stunting.pwn(2426) : error 010: invalid function or declaration
D:\samp folder\XtremeX-Stunting\gamemodes\XtremeX-Stunting.pwn(2430) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Line 2426:

PHP код:
else 
Line 2430:

PHP код:
return 1
Reply
#2

You have to do the if() statement then else. that's why it showing to you the errors.
Something like this:
PHP код:
CMD:back(playerid,params[]) 

if(function(
playerid))
{
new 
string[133]; 
format(string,sizeof(string),"** [{FF0000}%s]{FF00FF} Is Back",pName(playerid)); 
SendClientMessageToAll(playerid,string); 
TogglePlayerControllable(playerid,1); 

else 

SendClientMessage(playerid,-1,"You Not Afk"); 

return 
1

Reply
#3

Why don't you indent your code?
Код:
CMD:back(playerid,params[]) 
{ 
	new string[133]; 
	format(string,sizeof(string),"** [{FF0000}%s]{FF00FF} Is Back",pName(playerid)); 
	SendClientMessageToAll(playerid,string); 
	TogglePlayerControllable(playerid,1); 
} 
	else 
	{ 
		SendClientMessage(playerid,-1,"You Not Afk"); 
	} 
	return 1; 
}
I'm guessing there's a missing if statement?
Reply
#4

ok thanks thats fixed now the /afk

PHP код:
CMD:afk(playerid,params[])
{
if(
Afk[playerid] == 0)
{
new 
string[133],reason;
if(
sscanf(params,"ud",reason)) return SendClientMessage(playerid,0xFF0000FF,"USAGE: /afk [Reason]");
format(string,sizeof(string),"** [{FF0000}%s]{FF00FF} Is Now AFK Reason : %s",pName(playerid),reason);
SendClientMessageToAll(playerid,string);
Afk[playerid] = 1;
TogglePlayerControllable(playerid,0);
}
else
{
SendClientMessage(playerid,0xFF0000FF,"Error: You Already Afk, Use /back");
}
return 
1;

In Game It Dont SHow the reason
Reply
#5

PHP код:
SendClientMessageToAll(playerid,string); 
That's how the SendClientMessageToAll works:

PHP код:
SendClientMessageToAll(colorstring); 
Also you're are doing a wrong way with the sscanf, you have to put the value and "s" for string.
Change your code to this:

PHP код:
CMD:afk(playerid,params[])
{
    if(
Afk[playerid] == 0)
    {
        new 
string[133],reason[128];
        if(
sscanf(params,"s[128]"reason)) return SendClientMessage(playerid,0xFF0000FF,"USAGE: /afk [Reason]");
        
format(string,sizeof(string),"** [{FF0000}%s]{FF00FF} Is Now AFK Reason : %s",pName(playerid),reason);
        
SendClientMessageToAll(playerid,string);
        
Afk[playerid] = 1;
        
TogglePlayerControllable(playerid,0);
    }
    else
    {
        
SendClientMessage(playerid,0xFF0000FF,"Error: You Already Afk, Use /back");
    }
    return 
1;

Reply
#6

And please, intend your code it's will be more easier for you.
PHP код:
CMD:afk(playerid,params[])
{
    if(
Afk[playerid] == 0)
    {
        new 
string[133],reason;
        if(
sscanf(params,"ud",reason)) return SendClientMessage(playerid,0xFF0000FF,"USAGE: /afk [Reason]");
        
format(string,sizeof(string),"** [{FF0000}%s]{FF00FF} Is Now AFK Reason : %s",pName(playerid),reason);
        
SendClientMessageToAll(0xFF0000FF,string);
        
Afk[playerid] = 1;
        
TogglePlayerControllable(playeridfalse);
    }
    else
    {
        
SendClientMessage(playerid,0xFF0000FF,"Error: You Already Afk, Use /back");
    }
    return 
1;

Reply
#7

Change the int reason to an array.
And then change the format in sscanf too.
Reply
#8

Quote:
Originally Posted by oMa37
Посмотреть сообщение
PHP код:
SendClientMessageToAll(playerid,string); 
That's how the SendClientMessageToAll works:

PHP код:
SendClientMessageToAll(colorstring); 
Also you're are doing a wrong way with the sscanf, you have to put the value and "s" for string.
Change your code to this:

PHP код:
CMD:afk(playerid,params[])
{
    if(
Afk[playerid] == 0)
    {
        new 
string[133],reason[128];
        if(
sscanf(params,"s[128]"reason)) return SendClientMessage(playerid,0xFF0000FF,"USAGE: /afk [Reason]");
        
format(string,sizeof(string),"** [{FF0000}%s]{FF00FF} Is Now AFK Reason : %s",pName(playerid),reason);
        
SendClientMessageToAll(playerid,string);
        
Afk[playerid] = 1;
        
TogglePlayerControllable(playerid,0);
    }
    else
    {
        
SendClientMessage(playerid,0xFF0000FF,"Error: You Already Afk, Use /back");
    }
    return 
1;

Ty!!!!
Reply
#9

Anytime.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)