Respawn command
#1

Hello,

I just don't understand this. Normal this respawn command works. But now when I type ingame /respawn 0 it's saying that the player isn't connected. Code:

pawn Код:
//----------[Respawn]----------
CMD:respawn(playerid, params[])
    {
        {
        if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid,COLOR_RED,".:: You are not authorized to use this command ::.");

        new targetid;
        if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_DGREY"[CMD] / "#COL_SGREY"[PlayerID/PartOfName]");
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_ORANGE"[ERROR]"#COL_LRED" Player not connected!");
        else
        {
        new string[128];
        new pName[24], pTame[24];
        GetPlayerRame(playerid,pName,24);
        GetPlayerRame(targetid,pTame,24);
        format(string,sizeof string,""#COL_ORANGE"[SERVER]"#COL_LRED" %s has been respawned by Administrator %s.",pTame,pName);
        SendClientMessageToAll(COLOR_RED, string);
        SpawnPlayer(targetid);
        }
    }
        return 1;
    }
Reply
#2

Not sure, but, Try using (playerid) instead of (targetid)

Edit : Nvm didn't see new targetid;
Reply
#3

Quote:
Originally Posted by ElieJabbour
Посмотреть сообщение
Not sure, but, Try using (playerid) instead of (targetid)

Edit : Nvm didn't see new targetid;
Then the server returns 'Unknown command' for sure.
Reply
#4

He can't use playerid.

Playerid = admin/default person using the command.

Try this one, it isn't using sscanf, but works the same way:

pawn Код:
CMD:respawn(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid,COLOR_RED,".:: You are not authorized to use this command ::.");

    new targetid;
   
    targetid = strval(params); // string value
   
    if(!strlen(params)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /respawn [name / id]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_ORANGE"[ERROR]"#COL_LRED" Player not connected!");

    new string[128];
    new pName[24], pTame[24];
    GetPlayerRame(playerid,pName,24);
    GetPlayerRame(targetid,pTame,24);
    format(string,sizeof string,""#COL_ORANGE"[SERVER]"#COL_LRED" %s has been respawned by Administrator %s.",pTame,pName);
    SendClientMessageToAll(COLOR_RED, string);
    SpawnPlayer(targetid);
    return 1;
}
!strlen means if it's not the string length of the params (admin didn't include id, only typed /respawn), in this case: targetid.
Reply
#5

I Know, i didn't read the def neither, Its 6am and am still on samp -.-'
Reply
#6

what is GetPlayerRame? or were you meant to write name
Reply
#7

Quote:
Originally Posted by Mozz
Посмотреть сообщение
what is GetPlayerRame? or were you meant to write name
That's my own GetPlayerName. Nothing wrong with that. (GetPLayerName but only removing the bracket if RP name)
And I need one with SSCANF, because probably I'm getting this problem at every command. So I need to see what I'm doing wrong.
Reply
#8

If you are using sscanf plugin, download latest version.
Reply
#9

Already did, but probably still not fixed. So going to install sscanf again. Because I just don't see a script fail.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)