SA-MP Forums Archive
2 Questions with this 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: 2 Questions with this command. (/showthread.php?tid=185756)



2 Questions with this command. - Marshall_Banks - 26.10.2010

1. How come when i use it my server crashes (samp-server shuts off)
2. How can i make it so it only adds a clan/changes the clan tag instead of changing the whole name.
Код:
COMMAND:clantag(playerid, params[], cmdtext[])
{
new idx;
new string[256];
		new tmp[256];
		new tmpp[256];
		tmpp = strtok(cmdtext, idx);
		playerid = strval(tmpp);
		tmp = strtok(cmdtext, idx);
		if(IsPlayerConnected(playerid))
		{
					SetPlayerName(playerid, tmp);
					format(string, sizeof(string), "You changed your clantag to [%s]", tmp);
					SendClientMessage(playerid, blue, string);
				}
				return 1;

}



Re: 2 Questions with this command. - Haydz - 26.10.2010

1, make sure your gamemode compiles, if it doesn't it will just instantly shut off like you said.
or go throught server.cfg and double check everything is correct.
2,
Can't help sorry.


Re: 2 Questions with this command. - Marshall_Banks - 26.10.2010

Quote:
Originally Posted by Hayden_Bruin
Посмотреть сообщение
1, make sure your gamemode compiles, if it doesn't it will just instantly shut off like you said.
or go throught server.cfg and double check everything is correct.
2,
Can't help sorry.
The server crashes when i USE the command.
This forum requires that you wait 120 seconds between posts. Please try again in 77 seconds.


Re: 2 Questions with this command. - Scenario - 26.10.2010

I don't think you can actually change just the clan-tag. Simply change the entire name, adding the clan-tag in the front.

I don't see (from the code you gave) why it's closing the server. Could you show all of the code please?


Re: 2 Questions with this command. - Marshall_Banks - 26.10.2010

What do you mean by the whole code? That is the whole command and its the only command that crashs the server.


Re: 2 Questions with this command. - Scenario - 26.10.2010

Oh, sorry my bad. (horrible indentation)

You may want to fix your string size's - they're WAY to large. Not to mention, you should use sscanf.


Re: 2 Questions with this command. - Crayon - 26.10.2010

I'm a noob to scripting, but this could be a possible problem I suppose;

SetPlayerName(playerid, tmp);

I'm not sure if I'm getting this straight, but why do you have tmp in there?


Re: 2 Questions with this command. - Calgon - 26.10.2010

Your code is a horrible mess. Furthermore, you don't need an IPC check, the player is connected to have used the command.

pawn Код:
COMMAND:clantag(playerid, params[]) { // If you're using zcmd, you don't need 'cmdtext[]'
    if(!isnull(params)) {
        // The command contains a string that we can parse just by 'params'
        new
            playerClanTagandName[MAX_PLAYER_NAME], // For formatting the new player name
            playerName[MAX_PLAYER_NAME]; // Use the define/constant. It's 24, not 256.

        GetPlayerName(playerid, playerName, MAX_PLAYER_NAME); // Getting the players name.
       
        format(playerClanTagandName, MAX_PLAYER_NAME, "[%s]%s", params, playerName); // Formatting
        SetPlayerName(playerid, playerClanTagandName); // Setting the new name
    }
}
I assume that's what you originally wanted, it'd get the old name, put the clan tag in front, then change their name to it.