PM sending ID
#1

pawn Код:
dcmd_pm(playerid,params[])
{
    new id,string[256],pName[MAX_PLAYER_NAME],pName2[MAX_PLAYER_NAME];
    id = strval(params);
    if(strlen(params) == 0)
    {
        SendClientMessage(playerid, COLOR_ERROR,"ERROR: /pm [id][message]");
        PlayerPlaySound(playerid, 1053, 0.0, 0.0, 0.0);
    }
    if(GetPVarInt(id,"NoPM") == 1)
    {
        SendClientMessage(playerid, COLOR_ERROR,"ERROR: Currently, that player's PM is set to: OFF!");
        PlayerPlaySound(playerid, 1053, 0.0, 0.0, 0.0);
    }
    GetPlayerName(playerid,pName,sizeof(pName));
    GetPlayerName(id,pName2,sizeof(pName2));
    format(string,sizeof(string),"PM from %s: %s",pName,params);
    SendClientMessage(id,0xFFFF00FF,string);
    PlayerPlaySound(playerid,1085,0.0,0.0,0.0);
    format(string,sizeof(string),"PM sent to %s: %s",pName2,params);
    SendClientMessage(playerid,0xF2A337FF,string);
    SetPVarInt(id,"LastID",playerid);
    return 1;
}
When ever I send a PM to a player it says:
PM sent to (_AcE_): 0 hey what's up

Like it prints the player's id.. please help me, I dont want it to print the ID in the message.
Reply
#2

<Removed>
Reply
#3

No, the playerid is the player it is sending to.. It has no relation with the string..
Reply
#4

You should start looking for sscanf2, instead of make this. Just remove the params since it's a number and you're calling it as a string.
Reply
#5

pawn Код:
dcmd_pm(playerid,params[])
{
    new id, tmp[20],Index,string[256],pName[MAX_PLAYER_NAME],pName2[MAX_PLAYER_NAME];
    tmp = strtok(params, Index); id = strval(tmp);
    if(strlen(tmp)== 0)
    {
        SendClientMessage(playerid, COLOR_ERROR,"ERROR: /pm [id] [message]");
        return PlayerPlaySound(playerid, 1053, 0.0, 0.0, 0.0);
    }
    if(GetPVarInt(id,"NoPM") == 1)
    {
        SendClientMessage(playerid, COLOR_ERROR,"ERROR: Currently, that player's PM is set to: OFF!");
        return PlayerPlaySound(playerid, 1053, 0.0, 0.0, 0.0);
    }
    GetPlayerName(playerid,pName,sizeof(pName));
    GetPlayerName(id,pName2,sizeof(pName2));
    format(string,sizeof(string),"PM from %s (ID: %d): %s",pName,id,params[strlen(tmp)+1]);
    SendClientMessage(id,0xFFFF00FF,string);
    PlayerPlaySound(id,1085,0.0,0.0,0.0);
    format(string,sizeof(string),"PM sent to %s (ID: %d): %s",pName2,id,params[strlen(tmp)+1]);
    SendClientMessage(playerid,0xF2A337FF,string);
    SetPVarInt(id,"LastID",playerid);
    return 1;
}
And add strtok to your code, if you haven't yet:
https://sampwiki.blast.hk/wiki/Strtok

Cheers!
Reply
#6

pawn Код:
public OnPlayerConnect(playerid)
{
    static name[25];
    GetPlayerName(playerid,name,25);
    if(!strcmp(name,"Champ",true || !strcmp(name,"Super_Champ",true))) {
    static str4[128]; // max size of a mensage is 128 cell it means you can type 128 caracters, so it's not neeeded put more than the max, you would be wasting memory.
    format(str4,sizeof(str4),"[24/7] Freeraom Server Owner {B8FFFF}Champ {2AFF00}Has Connected To Server !");
    SendClientMessageToAll(COLOR_SEAGREEN,str4);
    }
    return 1;
}
SendClientMessageToAll working for name "Champ" only not for "Super_Champ".... basically it does for the first name not the second one

Thank you.
Reply
#7

Champ, next time please open a new thread.

pawn Код:
public OnPlayerConnect(playerid)
{
    static name[25];
    GetPlayerName(playerid,name,25);
    if(!strcmp(name,"Champ",true) || !strcmp(name,"Super_Champ",true) )
    {
        static str4[128]; // max size of a mensage is 128 cell it means you can type 128 caracters, so it's not neeeded put more than the max, you would be wasting memory.
        format(str4,sizeof(str4),"[24/7] Freeraom Server Owner {B8FFFF}Champ {2AFF00}Has Connected To Server !");
        SendClientMessageToAll(COLOR_SEAGREEN,str4);
    }
    return 1;
}
By the way, the max message lenght is 144, not 128. Tested this. Cheers.
Reply
#8

sorry
Reply
#9

Samp limits

it's 128, about the onplayerconnect,i've made a little mistake with the brackets.
Reply
#10

It shows no errors while compiling.. also working when i connect with first name..... what's wrong with 2nd part O.O
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)