Created
March 2, 2013 13:20
-
-
Save dennorske/5070924 to your computer and use it in GitHub Desktop.
Changename Command for Luxadmin (dcmd)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dcmd_changename(playerid,params[]) | |
{ | |
new file[80]; | |
new suspectname[MAX_PLAYER_NAME]; | |
new susfile[80]; | |
new string[180]; | |
new string2[180]; | |
new playernames[MAX_PLAYER_NAME]; | |
new Index; | |
new tmp[256]; tmp = strtok(params,Index); | |
new tmp2[256]; tmp2 = strtok(params,Index); | |
if(AccInfo[playerid][Level] < 5) | |
return ErrorMessages(playerid, 9); | |
if(!strlen(tmp) || !strlen(tmp2) || !IsNumeric(tmp)) | |
{ | |
SendClientMessage(playerid, LIGHTBLUE2, "Usage: /changename [playerid] {new name}"); | |
return SendClientMessage(playerid, orange, "Function: Will Change the name of the selected player"); | |
} | |
new suspect; suspect = strval(tmp); | |
if(suspect == INVALID_PLAYER_ID || !IsPlayerConnected(suspect)) | |
return ErrorMessages(playerid, 2); | |
if(strlen(tmp2) > 25) | |
return SendClientMessage(playerid, red, "This name is too long. Please select a shorter one. (Max 25 chars.)"); | |
GetPlayerName(suspect, suspectname, sizeof(suspectname)); | |
GetPlayerName(playerid, playernames, sizeof(playernames)); | |
format(file,sizeof(file),"/LuxAdmin/Accounts/%s.sav", suspectname); | |
format(susfile,sizeof(susfile),"/LuxAdmin/Accounts/%s.sav", tmp2); | |
if(fexist(susfile)) | |
return SendClientMessage(playerid, orange, "Sorry, this name is already in use by someoene else!"); | |
if(!fexist(file)) | |
return SendClientMessage(playerid, red, "This player is not registered"); | |
SetPlayerName(suspect, tmp2); | |
frename(file, susfile); | |
format(string, sizeof(string), "Owner %s set your name to %s. Remember to log in with this name next time!", playernames, tmp2); | |
SendClientMessage(suspect, green, string); | |
format(string2, sizeof(string2), "You set %s's name to %s sucessfully!", suspectname, tmp2); | |
SendClientMessage(playerid, green, string2); | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment