SA-MP Forums Archive
String problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: String problem (/showthread.php?tid=417301)



String problem - Da_Noob - 20.02.2013

So I'm making a voicemail, so whenever a player calls somebody the other player can leave a message. Then the other player can do /voicemail to check what somebody left.
But there's one problem: when I leave a message and do /voicemail the message doesn't show.

Code:

Under OnPlayerText

Код:
   	if(IsInVoicemail[playerid] == true)
	{
	    new msg[100];
		new pID = CalledABy[playerid];
	    format(msg,sizeof(msg),"(Cellphone) %s says: %s", GetName(playerid), text);
	    ProxDetector(5.0, playerid, msg, COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE);
	    format(msg,sizeof(msg),"%s", text);
	    Msg1Written[pID] = 1;
		Msg1[pID] = msg;
	}
CMD:

pawn Код:
CMD:voicemail(playerid)
{
    if(PlayerInfo[playerid][pPhone] <= 0) return SendClientMessage(playerid, COLOR_GRAD2, "You don't have a phone!");
    {
        new pID = CalledBy[playerid];
        new string[150];
        format(string,sizeof(string),"You have %d unread messages.", Msg1Written[playerid]);
        SendClientMessage(playerid, COLOR_GREEN, "Welcome to your voicemail!");
        SendClientMessage(playerid, COLOR_YELLOW, string);
       
        if(Msg1Written[playerid] == 1)
        {
            new str[150];
            SendClientMessage(playerid, COLOR_YELLOW, "___MESSAGE 1___");
            format(str,sizeof(str),"Sender (Number): %d",GetPlayerNumber(pID));
            SendClientMessage(playerid, COLOR_YELLOW, str);
            format(str,sizeof(str),Msg1[playerid]);
            SendClientMessage(playerid, COLOR_YELLOW, str);
        }
    }
    return 1;
}
I've tried to replace this:

pawn Код:
format(str,sizeof(str),Msg1[playerid]);
with this:

pawn Код:
format(str,sizeof(str),"%s", Msg1[playerid]);
Didn't work. I've also tried this:

pawn Код:
SendClientMessage(playerid, COLOR_YELLOW, Msg1[playerinfo]);
But that didn't work either. Any help?


Re: String problem - Goldino - 20.02.2013

Whats your line to get players mail?


Re: String problem - Da_Noob - 20.02.2013

I don't really know what you mean, but I guess you need this:

The line that should send the voicemail message:

pawn Код:
format(str,sizeof(str),Msg1[playerid]);
            SendClientMessage(playerid, COLOR_YELLOW, str);
And here is what Msg1[playerid] stores:

pawn Код:
format(msg,sizeof(msg),"%s", text);
        Msg1[pID] = msg;



Re: String problem - Da_Noob - 20.02.2013

Can somebody help me out here?


Re: String problem - ikey07 - 20.02.2013

have you tried strmid(Msg1[pID],msg,0,strlen(msg),255); ?