SA-MP Forums Archive
Respawn command - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Respawn command (/showthread.php?tid=277235)



Respawn command - Kingunit - 17.08.2011

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;
    }



Re: Respawn command - ElieJabbour - 17.08.2011

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

Edit : Nvm didn't see new targetid;


Re: Respawn command - Kingunit - 17.08.2011

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.


Re: Respawn command - grand.Theft.Otto - 17.08.2011

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.


Re: Respawn command - ElieJabbour - 17.08.2011

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


Re: Respawn command - Mozz - 17.08.2011

what is GetPlayerRame? or were you meant to write name


Re: Respawn command - Kingunit - 17.08.2011

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.


Re: Respawn command - MadeMan - 17.08.2011

If you are using sscanf plugin, download latest version.


Re: Respawn command - Kingunit - 17.08.2011

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