Problem with PM script
#1

I have a PM script that includes: /pm /reply /nopm(disables your pms)
When I type a message to someone like: /pm 2 Hey, whats up, I am fine, nice day, blah blah blah blah blah.
The the message is cut in the middle like there is a specific amount of max characters in a pm.How to change that?

pawn Код:
#include <a_samp>
#include <sscanf2>
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define COLOUR_SYSTEM   0xB60000FF
#define COLOUR_PM       0xFFFF2AFF
#define COLOUR_INFO     0x00983BFF

enum PM_PlayerData
{
    LastMessage,
    NoPM,
};
new PM_PlayerInfo[MAX_PLAYERS][PM_PlayerData];


public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(pm, 2, cmdtext);
    dcmd(reply, 5, cmdtext);
    dcmd(r, 1, cmdtext);
    dcmd(nopm, 4, cmdtext);
    return 0;
}
public OnFilterScriptInit()
{
    print("*****************************************************");
    print("      PM Successfully Loaded!        ");
    print("******************************************************");
    return 1;
}

public OnPlayerConnect(playerid)
{
    PM_PlayerInfo[playerid][LastMessage] = INVALID_PLAYER_ID;
    PM_PlayerInfo[playerid][NoPM] = 0;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    PM_PlayerInfo[playerid][LastMessage] = INVALID_PLAYER_ID;
    PM_PlayerInfo[playerid][NoPM] = 0;
    return 1;
}
stock pNick(playerid)
{
    new nick[MAX_PLAYER_NAME];
    GetPlayerName(playerid, nick, MAX_PLAYER_NAME);
    return nick;
}
dcmd_pm(playerid, params[])
{
        new id, msg[75], string[200];
        if(sscanf(params, "us", id, msg)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /pm (nick/id) (message)");
        if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid Player!");
        if(id == playerid) return SendClientMessage(playerid, COLOUR_SYSTEM, "You Can Not PM Yourself!");
        if(PM_PlayerInfo[id][NoPM] == 1) return SendClientMessage(playerid, COLOUR_PM, "This player has disable pm.");
        format(string,sizeof(string),"PM Sent To %s (%d): %s", pNick(id), id, msg);
        SendClientMessage(playerid, COLOUR_PM, string);
        format(string,sizeof(string),"PM From %s (%d): %s", pNick(playerid), playerid, msg);
        SendClientMessage(id, COLOUR_PM, string);
        SendClientMessage(id, COLOUR_INFO, "Type /reply or /r To Quick Reply And /nopm To Disable Pms.");
        PM_PlayerInfo[id][LastMessage] = playerid;
        return 1;
}
dcmd_reply(playerid, params[])
{
        new msg[75], string[200];
        new id = PM_PlayerInfo[playerid][LastMessage];
        if(sscanf(params, "s", msg)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /reply (text)");
        if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid Player!");
        if(PM_PlayerInfo[id][NoPM] == 1) return format(string,sizeof(string),"%s (%d) Is Not Accepting His PMs At The Moment.", pNick(id), id); SendClientMessage(playerid, COLOUR_PM, string);
        format(string,sizeof(string),"PM Sent To %s (%d): %s", pNick(id), id, msg);
        SendClientMessage(playerid, COLOUR_PM, string);
        format(string,sizeof(string),"PM From %s (%d): %s", pNick(playerid), playerid, msg);
        SendClientMessage(id, COLOUR_PM, string);
        SendClientMessage(id, COLOUR_INFO, "Type /reply or /r To Quick Reply And /nopm To Disable Pms.");
        PM_PlayerInfo[id][LastMessage] = playerid;
        return 1;
}
dcmd_r(playerid, params[])
{
    return dcmd_reply(playerid, params);
}

dcmd_nopm(playerid,params[])
{
    #pragma unused params
    if (PM_PlayerInfo[playerid][NoPM] == 1)
    {
        PM_PlayerInfo[playerid][NoPM] = 0;
        SendClientMessage(playerid,0xFFFF00FF,"Pm's on!");
    }
    else
    {
        PM_PlayerInfo[playerid][NoPM] = 1;
        SendClientMessage(playerid,0xFFFF00FF,"Pm's off!");
    }
    return 1;
}

/*

dcmd_nopm(playerid, params[])
{


    new amount;
    if(sscanf(params, "d", amount)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /nopm (Toggle: 0/1)");
    if(amount < 0 || amount > 1) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /nopm (Toggle: 0/1)");
    if(amount == 0)
    {
        PM_PlayerInfo[playerid][NoPM] = 0;
        SendClientMessage(playerid, COLOUR_PM, "You Have Enabled Incomming PMs. Use /nopm To Disable PMs.");
    }
    if(amount == 1)
    {
        PM_PlayerInfo[playerid][NoPM] = 1;
        SendClientMessage(playerid, COLOUR_PM, "You Have Disabled Incomming PMs. Use /nopm To Enable PMs.");
    }
    return 1;
}

*/
Reply
#2

Increase the string size..

msg[75]; this needs to be higher..
Reply
#3

Quote:
Originally Posted by Jari_Johnson*
Посмотреть сообщение
Increase the string size..

msg[75]; this needs to be higher..
I have already done it and it doesnt increase the characters much enough.If I put it above arround 4000 this message will appear at the complile box:


Header size: 684 bytes
Code size: 28756 bytes
Data size: 19068 bytes
Stack/heap size: 16384 bytes; estimated max. usage=276447504 cells (1105790016 bytes)
Total requirements: 64892 bytes




I want it like to fill a whole line in the screen.
Reply
#4

XD You don't need 4000 of bytes to process it

Set it to 128 or if still not then, 256 (not really necessary)
Reply
#5

Didn't help actually, I will find another script.
Reply
#6

This might help

PHP код:
new togglepm[MAX_PLAYERS],ID,message[128],str[128],Nam[MAX_PLAYER_NAME],Pname[MAX_PLAYER_NAME];
public 
OnPlayerConnect(playerid)
{
    
togglepm[playerid] = 1;
    return 
1;
}
CMD:pm(playeridparams[])
{
    if(
sscanf(params,"us",ID,message)) return SendClientMessage(playerid,0xF6BB0AA,"USAGE: /pm [ID] [message]");
    if(!
IsPlayerConnected(ID)) return SendClientMessage(playerid,0xFF0000FF,"Invalid ID");
    if(
togglepm[ID] == 0) return SendClientMessage(playerid,0xFB0000AA,"ERROR: That user has his pm toggled off");
    
GetPlayerName(ID,Pname,sizeof(Pname));
    
GetPlayerName(playerid,Nam,sizeof(Nam));
    
format(str,sizeof(str),">> %s(%d): %s",Pname,playerid,message);
    
SendClientMessage(playerid,0xFFFF00FF,str);
    
format(str,sizeof(str),"** %s(%d): %s",Nam,playerid,message);
    
SendClientMessage(ID,0xFFFF00FF,str);
    return 
1;
}
CMD:togglepm(playerid,params[])
{
    if(
togglepm[playerid] == 1)
    {
        
SendClientMessage(playerid,0xF6BB0AA,"You had toggled your pm OFF");
        
togglepm[playerid] = 0;
    }
    else if(
togglepm[playerid] == 0)
    {
        
SendClientMessage(playerid,0xF6BB0AA,"You had toggled your pm ON");
        
togglepm[playerid] = 1;
    }
    return 
1;

Reply
#7

Quote:
Originally Posted by Ken97
Посмотреть сообщение
This might help

PHP код:
new togglepm[MAX_PLAYERS],ID,message[128],str[128],Nam[MAX_PLAYER_NAME],Pname[MAX_PLAYER_NAME];
public 
OnPlayerConnect(playerid)
{
    
togglepm[playerid] = 1;
    return 
1;
}
CMD:pm(playeridparams[])
{
    if(
sscanf(params,"us",ID,message)) return SendClientMessage(playerid,0xF6BB0AA,"USAGE: /pm [ID] [message]");
    if(!
IsPlayerConnected(ID)) return SendClientMessage(playerid,0xFF0000FF,"Invalid ID");
    if(
togglepm[ID] == 0) return SendClientMessage(playerid,0xFB0000AA,"ERROR: That user has his pm toggled off");
    
GetPlayerName(ID,Pname,sizeof(Pname));
    
GetPlayerName(playerid,Nam,sizeof(Nam));
    
format(str,sizeof(str),">> %s(%d): %s",Pname,playerid,message);
    
SendClientMessage(playerid,0xFFFF00FF,str);
    
format(str,sizeof(str),"** %s(%d): %s",Nam,playerid,message);
    
SendClientMessage(ID,0xFFFF00FF,str);
    return 
1;
}
CMD:togglepm(playerid,params[])
{
    if(
togglepm[playerid] == 1)
    {
        
SendClientMessage(playerid,0xF6BB0AA,"You had toggled your pm OFF");
        
togglepm[playerid] = 0;
    }
    else if(
togglepm[playerid] == 0)
    {
        
SendClientMessage(playerid,0xF6BB0AA,"You had toggled your pm ON");
        
togglepm[playerid] = 1;
    }
    return 
1;

pawn Код:
#include <a_samp>
#include <sscanf2>
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define COLOUR_SYSTEM   0xB60000FF
#define COLOUR_PM       0xFFFF2AFF
#define COLOUR_INFO     0x00983BFF


new togglepm[MAX_PLAYERS],ID,message[128],str[128],Nam[MAX_PLAYER_NAME],Pname[MAX_PLAYER_NAME];

public OnPlayerConnect(playerid)
{
    togglepm[playerid] = 1;
    return 1;
}
CMD:pm(playerid, params[])
{
    if(sscanf(params,"us",ID,message)) return SendClientMessage(playerid,0xF6BB0AA,"USAGE: /pm [ID] [message]");
    if(!IsPlayerConnected(ID)) return SendClientMessage(playerid,0xFF0000FF,"Invalid ID");
    if(togglepm[ID] == 0) return SendClientMessage(playerid,0xFB0000AA,"ERROR: That user has his pm toggled off");
    GetPlayerName(ID,Pname,sizeof(Pname));
    GetPlayerName(playerid,Nam,sizeof(Nam));
    format(str,sizeof(str),">> %s(%d): %s",Pname,playerid,message);
    SendClientMessage(playerid,0xFFFF00FF,str);
    format(str,sizeof(str),"** %s(%d): %s",Nam,playerid,message);
    SendClientMessage(ID,0xFFFF00FF,str);
    return 1;
}
CMD:togglepm(playerid,params[])
{
    if(togglepm[playerid] == 1)
    {
        SendClientMessage(playerid,0xF6BB0AA,"You had toggled your pm OFF");
        togglepm[playerid] = 0;
    }
    else if(togglepm[playerid] == 0)
    {
        SendClientMessage(playerid,0xF6BB0AA,"You had toggled your pm ON");
        togglepm[playerid] = 1;
    }
    return 1;
}
Errors:


C:\Documents and Settings\Nikos\ЕрйцЬнейб есгбуЯбт\samp server testing\filterscripts\nopm.pwn(29) : error 021: symbol already defined: "togglepm"
C:\Documents and Settings\Nikos\ЕрйцЬнейб есгбуЯбт\samp server testing\filterscripts\nopm.pwn(31) : error 010: invalid function or declaration
C:\Documents and Settings\Nikos\ЕрйцЬнейб есгбуЯбт\samp server testing\filterscripts\nopm.pwn(36) : error 010: invalid function or declaration
C:\Documents and Settings\Nikos\ЕрйцЬнейб есгбуЯбт\samp server testing\filterscripts\nopm.pwn(41) : error 010: invalid function or declaration
C:\Documents and Settings\Nikos\ЕрйцЬнейб есгбуЯбт\samp server testing\filterscripts\nopm.pwn(43) : warning 203: symbol is never used: "pm"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#8

maybe that??
pawn Код:
#include <a_samp>
#include <sscanf2>
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define COLOUR_SYSTEM   0xB60000FF
#define COLOUR_PM       0xFFFF2AFF
#define COLOUR_INFO     0x00983BFF

enum PM_PlayerData
{
    LastMessage,
    NoPM,
};
new PM_PlayerInfo[MAX_PLAYERS][PM_PlayerData];


public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(pm, 2, cmdtext);
    dcmd(reply, 5, cmdtext);
    dcmd(r, 1, cmdtext);
    dcmd(nopm, 4, cmdtext);
    return 0;
}
public OnFilterScriptInit()
{
    print("*****************************************************");
    print("      PM Successfully Loaded!        ");
    print("******************************************************");
    return 1;
}

public OnPlayerConnect(playerid)
{
    PM_PlayerInfo[playerid][LastMessage] = INVALID_PLAYER_ID;
    PM_PlayerInfo[playerid][NoPM] = 0;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    PM_PlayerInfo[playerid][LastMessage] = INVALID_PLAYER_ID;
    PM_PlayerInfo[playerid][NoPM] = 0;
    return 1;
}
stock pNick(playerid)
{
    new nick[MAX_PLAYER_NAME];
    GetPlayerName(playerid, nick, MAX_PLAYER_NAME);
    return nick;
}
dcmd_pm(playerid, params[])
{
        new id, msg[256], string[200];
        if(sscanf(params, "us[256]", id, msg)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /pm (nick/id) (message)");
        if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid Player!");
        if(id == playerid) return SendClientMessage(playerid, COLOUR_SYSTEM, "You Can Not PM Yourself!");
        if(PM_PlayerInfo[id][NoPM] == 1) return SendClientMessage(playerid, COLOUR_PM, "This player has disable pm.");
        format(string,sizeof(string),"PM Sent To %s (%d): %s", pNick(id), id, msg);
        SendClientMessage(playerid, COLOUR_PM, string);
        format(string,sizeof(string),"PM From %s (%d): %s", pNick(playerid), playerid, msg);
        SendClientMessage(id, COLOUR_PM, string);
        SendClientMessage(id, COLOUR_INFO, "Type /reply or /r To Quick Reply And /nopm To Disable Pms.");
        PM_PlayerInfo[id][LastMessage] = playerid;
        return 1;
}
dcmd_reply(playerid, params[])
{
        new msg[256], string[200];
        new id = PM_PlayerInfo[playerid][LastMessage];
        if(sscanf(params, "s[256]", msg)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /reply (text)");
        if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid Player!");
        if(PM_PlayerInfo[id][NoPM] == 1) return format(string,sizeof(string),"%s (%d) Is Not Accepting His PMs At The Moment.", pNick(id), id); SendClientMessage(playerid, COLOUR_PM, string);
        format(string,sizeof(string),"PM Sent To %s (%d): %s", pNick(id), id, msg);
        SendClientMessage(playerid, COLOUR_PM, string);
        format(string,sizeof(string),"PM From %s (%d): %s", pNick(playerid), playerid, msg);
        SendClientMessage(id, COLOUR_PM, string);
        SendClientMessage(id, COLOUR_INFO, "Type /reply or /r To Quick Reply And /nopm To Disable Pms.");
        PM_PlayerInfo[id][LastMessage] = playerid;
        return 1;
}
dcmd_r(playerid, params[])
{
    return dcmd_reply(playerid, params);
}

dcmd_nopm(playerid,params[])
{
    #pragma unused params
    if (PM_PlayerInfo[playerid][NoPM] == 1)
    {
        PM_PlayerInfo[playerid][NoPM] = 0;
        SendClientMessage(playerid,0xFFFF00FF,"Pm's on!");
    }
    else
    {
        PM_PlayerInfo[playerid][NoPM] = 1;
        SendClientMessage(playerid,0xFFFF00FF,"Pm's off!");
    }
    return 1;
}

/*

dcmd_nopm(playerid, params[])
{


    new amount;
    if(sscanf(params, "d", amount)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /nopm (Toggle: 0/1)");
    if(amount < 0 || amount > 1) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /nopm (Toggle: 0/1)");
    if(amount == 0)
    {
        PM_PlayerInfo[playerid][NoPM] = 0;
        SendClientMessage(playerid, COLOUR_PM, "You Have Enabled Incomming PMs. Use /nopm To Disable PMs.");
    }
    if(amount == 1)
    {
        PM_PlayerInfo[playerid][NoPM] = 1;
        SendClientMessage(playerid, COLOUR_PM, "You Have Disabled Incomming PMs. Use /nopm To Enable PMs.");
    }
    return 1;
}

*/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)