Roleplay command help
#1

I have a /me command but it has errors can someone help me can someone also tell me how to make a /ame (/me above head) and a /b (out of character)
Here is the /me code
PHP код:
    CMD:me(playeridparams[])
    {
    new
    
string[128],
    
action[100];
    if(
sscanf(params"s[100]"action))
    {
    
SendClientMessage(playerid, -1"USAGE: /me [action]");
    return 
1;
    }
    else
    {
    
format(stringsizeof(string), "* %s %s"GetName(playerid), action);
    
ProxDetector(30playeridstringPURPLE);
    }
    return 
1;
    } 
And here are the errors
PHP код:
C:\Users\logan_000\Desktop\Samp server\gamemodes\lramos15.pwn(395) : error 029invalid expressionassumed zero
C
:\Users\logan_000\Desktop\Samp server\gamemodes\lramos15.pwn(395) : error 017undefined symbol "cmd_me"
C:\Users\logan_000\Desktop\Samp server\gamemodes\lramos15.pwn(395) : error 029invalid expressionassumed zero
C
:\Users\logan_000\Desktop\Samp server\gamemodes\lramos15.pwn(395) : fatal error 107too many error messages on one line 
Reply
#2

Top..

pawn Код:
#include <zcmd>
Reply
#3

-DELETED-
Reply
#4

I have include zcmd at the top
Reply
#5

pawn Код:
CMD:me(playerid, params[])
{
    if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /me [action]"); //This would be detecting, if the player types nothing, it will return him the ClientMessage stated above.
    new str[500], pName[MAX_PLAYER_NAME]; //The text the player will type, and the player name..
    GetPlayerName(playerid, pName, sizeof(pName)); //This gets the player name...
    format(str, sizeof(str), " * %s %s", pName, params); //This format gets what the player types
    SendClientMessageToAll(-1, str); // and here it sends the string
    return 1;
}
No need of all that ..
Reply
#6

Quote:
Originally Posted by Strier
Посмотреть сообщение
pawn Код:
CMD:me(playerid, params[])
{
    if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /me [action]"); //This would be detecting, if the player types nothing, it will return him the ClientMessage stated above.
    new str[500], pName[MAX_PLAYER_NAME]; //The text the player will type, and the player name..
    GetPlayerName(playerid, pName, sizeof(pName)); //This gets the player name...
    format(str, sizeof(str), " * %s %s", pName, params); //This format gets what the player types
    SendClientMessageToAll(-1, str); // and here it sends the string
    return 1;
}
No need of all that ..
This^^ will send the message to all the players and if you want the cmd for nearby players use this.

pawn Код:
CMD:me(playerid, params[])
{
    if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /me [action]"); //This would be detecting, if the player types nothing, it will return him the ClientMessage stated above.
    new str[500], pName[MAX_PLAYER_NAME]; //The text the player will type, and the player name..
    GetPlayerName(playerid, pName, sizeof(pName)); //This gets the player name...
    format(str, sizeof(str), " * %s %s", pName, params); //This format gets what the player types
    SendNearbyMessage(playerid, 15, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);// and here it sends the string
    return 1;
}
here is the /b cmd for local ooc chat
pawn Код:
CMD:b(playerid, params[])
{
    new string[128];
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /b [text] (Local OOC Chat)");
        GetPlayerName(playerid, pName, sizeof(pName)); //This gets the player name...
    format(string, sizeof(string), "%s: (( %s ))", pName, params); //This format gets what the player types
    SendNearbyMessage(playerid, 10, string, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
    return 1;
}
didn't tested the /b cmd.
Reply
#7

After testing your code I realized the command itself wasn't causing the error please help
PHP код:
CMD:uncuff(playeridparams[])
    {
    new 
targetid;//this defines the id of the player you want to cuff((playerid id your id and the target id that I defined it the id of the player you want to cuff))
     
if(sscanf(params"r"targetid)) return SendClientMessage(playerid, -1"[USAGE]: /uncuff [Part of Name/Player ID]");
      if(
IsPlayerConnected(targetid))//this will check that if the player you want to cuff is connected to the server or not.
       
{
    new 
Float:xFloat:yFloat:z;//these are the defines of your x,y and z position.
    
GetPlayerPos(playeridxyz);//this will store your position to be used in the following codes.((this stores the your x,y, and z position in to the variables we created.))
    
if(IsPlayerInRangeOfPoint(targetid5.0xyz))//this will check that if the player you want to cuff is near you or not.
    
{
    if(!
SetPlayerAttachedObject(targetid0194186, -0.0110000.028000, -0.022000, -15.600012, -33.699977,-81.7000350.8919991.0000001.168000))return SendClientMessage(playerid,-1,"ERROR: The player is not cuffed!");//this will check that if the player is not cuffed and you are trying to apply this cmd,this will send him a error message.
    
SetPlayerSpecialAction(targetid,SPECIAL_ACTION_NONE);//this will remove the players cuffs and his arms will go normal.
    
RemovePlayerAttachedObject(targetid0); // This will remove the cuff object!
    
new str[50];//this it the define for the string you will format further.((str means string.You can also change it to string but this seems to be easy.))
    
new name[MAX_PLAYER_NAME];//this is the variable you created to store your name.
    
GetPlayerName(playeridnamesizeof(name));//this will get your name and store it in the variable you defines as name.
    
new target[MAX_PLAYER_NAME];//this is the variable you created to store the name of the player you want to cuff.
    
GetPlayerName(targetidtargetsizeof(target));//this will get the name of the person you want to cuff and will store it into a variable we defined as target.
    
format(strsizeof(str), "INFO: You have uncuffed %s!",target);//explained at the end of the tutorial.
    
SendClientMessage(playerid0xE01B1Bstr);//will send the formated message to you that you created above.
    
format(strsizeof(str), "WARNING: You have been uncuffed by %s!",name);//explained bellow.
    
SendClientMessage(targetid0xE01B1Bstr);//will send the formated message to the player you want to cuff that you created above.
    
return 1;
    }
    }
       
CMD:me(playeridparams[])
    {
    if(
isnull(params)) return SendClientMessage(playerid, -1"Usage: /me [action]"); //This would be detecting, if the player types nothing, it will return him the ClientMessage stated above.
    
new str[500], action[100]; //The text the player will type, and the player name..
    
format(strsizeof(str), " * %s %s"GetName(playerid),action//This format gets what the player types
    
ProxDetector(30strPURPLE);// and here it sends the string
    
return 1;
    }
    
CMD:shout(playeridparams[])
    {
    new
    
string[128],
    
shout[100];
    if(
sscanf(params"s[100]"shout))
    {
    
SendClientMessage(playerid, -1"USAGE: /shout [message]");
    return 
1;
    }
    else
    {
    
format(stringsizeof(string), "%s shouts: %s!",GetName(playerid),shout);
    
ProxDetector(50.0playeridstring, -1);
    }
    return 
1;
    }
    
CMD:low(playeridparams[])
    {
    new
    
string[128],
    
low[100];
    if(
sscanf(params"s[100]"low))
    {
    
SendClientMessage(playerid, -1"USAGE: /low [message]");
    return 
1;
    }
    else
    {
    
format(stringsizeof(string), "%s low: %s.",GetName(playerid),low);
    
ProxDetector(10.0playeridstring, -1);
    }
    return 
1;
    }
    
CMD:do(playeridparams[])
    {
    new
    
string[128],
    
action[100];
    if(
sscanf(params"s[100]"action))
    {
    
SendClientMessage(playerid, -1"USAGE: /do [action]");
    return 
1;
    }
    else
    {
    
format(stringsizeof(string), "* %s (( %s ))"paramsGetName(playerid));
     
ProxDetector(30playeridstringPURPLE);
    }
    return 
1;
    }
    
CMD:b(playeridparams[])
    {
    new 
string[128],pName[MAX_PLAYER_NAME];
    if(
sscanf(params"s[128]"params)) return SendClientMessage(playerid,WHITE"USAGE: /b [text] (Local OOC Chat)");
    
GetPlayerName(playeridpNamesizeof(pName)); //This gets the player name...
    
format(stringsizeof(string), "%s: (( %s ))"pNameparams); //This format gets what the player types
    
ProxDetector(30,playeridstring,GREY);
    return 
1;
    }
    return 
1;
    } 
Here are the errors
PHP код:
C:\Users\logan_000\Desktop\Samp server\gamemodes\lramos15.pwn(395) : error 029invalid expressionassumed zero
C
:\Users\logan_000\Desktop\Samp server\gamemodes\lramos15.pwn(395) : error 017undefined symbol "cmd_me"
C:\Users\logan_000\Desktop\Samp server\gamemodes\lramos15.pwn(395) : error 029invalid expressionassumed zero
C
:\Users\logan_000\Desktop\Samp server\gamemodes\lramos15.pwn(395) : fatal error 107too many error messages on one line
Compilation aborted
.Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
4 Errors

Reply
#8

Forgot 1 bracket
Try this:
pawn Код:
CMD:uncuff(playerid, params[])
    {
    new targetid;//this defines the id of the player you want to cuff((playerid id your id and the target id that I defined it the id of the player you want to cuff))
     if(sscanf(params, "r", targetid)) return SendClientMessage(playerid, -1, "[USAGE]: /uncuff [Part of Name/Player ID]");
      if(IsPlayerConnected(targetid))//this will check that if the player you want to cuff is connected to the server or not.
       {
    new Float:x, Float:y, Float:z;//these are the defines of your x,y and z position.
    GetPlayerPos(playerid, x, y, z);//this will store your position to be used in the following codes.((this stores the your x,y, and z position in to the variables we created.))
    if(IsPlayerInRangeOfPoint(targetid, 5.0, x, y, z))//this will check that if the player you want to cuff is near you or not.
    {
    if(!SetPlayerAttachedObject(targetid, 0, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977,-81.700035, 0.891999, 1.000000, 1.168000))return SendClientMessage(playerid,-1,"ERROR: The player is not cuffed!");//this will check that if the player is not cuffed and you are trying to apply this cmd,this will send him a error message.
    SetPlayerSpecialAction(targetid,SPECIAL_ACTION_NONE);//this will remove the players cuffs and his arms will go normal.
    RemovePlayerAttachedObject(targetid, 0); // This will remove the cuff object!
    new str[50];//this it the define for the string you will format further.((str means string.You can also change it to string but this seems to be easy.))
    new name[MAX_PLAYER_NAME];//this is the variable you created to store your name.
    GetPlayerName(playerid, name, sizeof(name));//this will get your name and store it in the variable you defines as name.
    new target[MAX_PLAYER_NAME];//this is the variable you created to store the name of the player you want to cuff.
    GetPlayerName(targetid, target, sizeof(target));//this will get the name of the person you want to cuff and will store it into a variable we defined as target.
    format(str, sizeof(str), "INFO: You have uncuffed %s!",target);//explained at the end of the tutorial.
    SendClientMessage(playerid, 0xE01B1B, str);//will send the formated message to you that you created above.
    format(str, sizeof(str), "WARNING: You have been uncuffed by %s!",name);//explained bellow.
    SendClientMessage(targetid, 0xE01B1B, str);//will send the formated message to the player you want to cuff that you created above.
    return 1;
    }
    }
    }
       CMD:me(playerid, params[])
    {
    if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /me [action]"); //This would be detecting, if the player types nothing, it will return him the ClientMessage stated above.
    new str[500], action[100]; //The text the player will type, and the player name..
    format(str, sizeof(str), " * %s %s", GetName(playerid),action; //This format gets what the player types
    ProxDetector(30, str, PURPLE);// and here it sends the string
    return 1;
    }
    CMD:shout(playerid, params[])
    {
    new
    string[128],
    shout[100];
    if(sscanf(params, "s[100]", shout))
    {
    SendClientMessage(playerid, -1, "USAGE: /shout [message]");
    return 1;
    }
    else
    {
    format(string, sizeof(string), "%s shouts: %s!",GetName(playerid),shout);
    ProxDetector(50.0, playerid, string, -1);
    }
    return 1;
    }
    CMD:low(playerid, params[])
    {
    new
    string[128],
    low[100];
    if(sscanf(params, "s[100]", low))
    {
    SendClientMessage(playerid, -1, "USAGE: /low [message]");
    return 1;
    }
    else
    {
    format(string, sizeof(string), "%s low: %s.",GetName(playerid),low);
    ProxDetector(10.0, playerid, string, -1);
    }
    return 1;
    }
    CMD:do(playerid, params[])
    {
    new
    string[128],
    action[100];
    if(sscanf(params, "s[100]", action))
    {
    SendClientMessage(playerid, -1, "USAGE: /do [action]");
    return 1;
    }
    else
    {
    format(string, sizeof(string), "* %s (( %s ))", params, GetName(playerid));
     ProxDetector(30, playerid, string, PURPLE);
    }
    return 1;
    }
    CMD:b(playerid, params[])
    {
    new string[128],pName[MAX_PLAYER_NAME];
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid,WHITE, "USAGE: /b [text] (Local OOC Chat)");
    GetPlayerName(playerid, pName, sizeof(pName)); //This gets the player name...
    format(string, sizeof(string), "%s: (( %s ))", pName, params); //This format gets what the player types
    ProxDetector(30,playerid, string,GREY);
    return 1;
    }
    return 1;
    }
Reply
#9

That got rid of one error but I still am getting errors here are the errors
PHP код:
C:\Users\logan_000\Desktop\Samp server\gamemodes\lramos15.pwn(395) : warning 209: function "cmd_uncuff" should return a value
C
:\Users\logan_000\Desktop\Samp server\gamemodes\lramos15.pwn(400) : error 001expected token","but found ";"
C:\Users\logan_000\Desktop\Samp server\gamemodes\lramos15.pwn(401) : error 035argument type mismatch (argument 2)
C:\Users\logan_000\Desktop\Samp server\gamemodes\lramos15.pwn(464) : error 010invalid function or declaration
C
:\Users\logan_000\Desktop\Samp server\gamemodes\lramos15.pwn(666) : warning 203symbol is never used"gTeam"
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
3 Errors

Here is the code.
PHP код:
CMD:uncuff(playeridparams[])
    {
    new 
targetid;//this defines the id of the player you want to cuff((playerid id your id and the target id that I defined it the id of the player you want to cuff))
     
if(sscanf(params"r"targetid)) return SendClientMessage(playerid, -1"[USAGE]: /uncuff [Part of Name/Player ID]");
      if(
IsPlayerConnected(targetid))//this will check that if the player you want to cuff is connected to the server or not.
       
{
    new 
Float:xFloat:yFloat:z;//these are the defines of your x,y and z position.
    
GetPlayerPos(playeridxyz);//this will store your position to be used in the following codes.((this stores the your x,y, and z position in to the variables we created.))
    
if(IsPlayerInRangeOfPoint(targetid5.0xyz))//this will check that if the player you want to cuff is near you or not.
    
{
    if(!
SetPlayerAttachedObject(targetid0194186, -0.0110000.028000, -0.022000, -15.600012, -33.699977,-81.7000350.8919991.0000001.168000))return SendClientMessage(playerid,-1,"ERROR: The player is not cuffed!");//this will check that if the player is not cuffed and you are trying to apply this cmd,this will send him a error message.
    
SetPlayerSpecialAction(targetid,SPECIAL_ACTION_NONE);//this will remove the players cuffs and his arms will go normal.
    
RemovePlayerAttachedObject(targetid0); // This will remove the cuff object!
    
new str[50];//this it the define for the string you will format further.((str means string.You can also change it to string but this seems to be easy.))
    
new name[MAX_PLAYER_NAME];//this is the variable you created to store your name.
    
GetPlayerName(playeridnamesizeof(name));//this will get your name and store it in the variable you defines as name.
    
new target[MAX_PLAYER_NAME];//this is the variable you created to store the name of the player you want to cuff.
    
GetPlayerName(targetidtargetsizeof(target));//this will get the name of the person you want to cuff and will store it into a variable we defined as target.
    
format(strsizeof(str), "INFO: You have uncuffed %s!",target);//explained at the end of the tutorial.
    
SendClientMessage(playerid0xE01B1Bstr);//will send the formated message to you that you created above.
    
format(strsizeof(str), "WARNING: You have been uncuffed by %s!",name);//explained bellow.
    
SendClientMessage(targetid0xE01B1Bstr);//will send the formated message to the player you want to cuff that you created above.
    
return 1;
    }
    }
    }
       
CMD:me(playeridparams[])
    {
    if(
isnull(params)) return SendClientMessage(playerid, -1"Usage: /me [action]"); //This would be detecting, if the player types nothing, it will return him the ClientMessage stated above.
    
new str[500], action[100]; //The text the player will type, and the player name..
    
format(strsizeof(str), " * %s %s"GetName(playerid),action//This format gets what the player types
    
ProxDetector(30strPURPLE);// and here it sends the string
    
return 1;
    } 
Here are the specific lines causing the error
395
PHP код:

400
PHP код:
format(strsizeof(str), " * %s %s"GetName(playerid),action//This format gets what the player types 
401
PHP код:
ProxDetector(30strPURPLE);// and here it sends the string 
464 Ignore I fixed it I had too many returns
Here are my functions
PHP код:
//===============[Defines string replace function]=========================
    
stock namechange(string[], findreplace)
    {
    for(new 
i=0string[i]; i++)
    {
    if(
string[i] == find)
    {
    
string[i] = replace;
     }
    }
    }
//---------------------[ Gets  name]-----------------------------------------
stock GetName(playerid)
{
    new
        
name[24];
    
GetPlayerName(playeridnamesizeof(name));
    
namechange(name'_'' ');
    return 
name;
}
//--------------------[Detects range for chat]-------------------------------
stock ProxDetector(Float:radiplayeridstring[],color)
{
    new 
Float:x,Float:y,Float:z;
    
GetPlayerPos(playerid,x,y,z);
    foreach(
Player,i)
    {
        if(
IsPlayerInRangeOfPoint(i,radi,x,y,z))
        {
            
SendClientMessage(i,color,string);
        }
    }

I think that's everything if you need more just ask
Reply
#10

Sorry I just fixed these Three errors
PHP код:
C:\Users\logan_000\Desktop\Samp server\gamemodes\lramos15.pwn(401) : error 035argument type mismatch (argument 2
C:\Users\logan_000\Desktop\Samp server\gamemodes\lramos15.pwn(464) : error 010invalid function or declaration 
C
:\Users\logan_000\Desktop\Samp server\gamemodes\lramos15.pwn(400) : error 001expected token","but found ";" 
So if anyone could help with the return warning that would be great
C:\Users\logan_000\Desktop\Samp server\gamemodes\lramos15.pwn(395) : warning 209: function "cmd_uncuff" should return a value
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)