Help With getting name -
AroseKhanNiazi - 30.03.2014
Код:
CMD:explode(playerid,params[])
{
if(pInfo[playerid][Adminlevel] < 5) return SendClientMessage(playerid, COLOR_RED, ""ERROR_MESSAGE"");
new TargetID, reason[20];
new targetname[MAX_PLAYER_NAME];
GetPlayerName(TargetID, targetname, sizeof(targetname));
if(sscanf(params, "us", TargetID, reason)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /explode [id] [reason]");
if(TargetID == INVALID_PLAYER_ID || !IsPlayerConnected(TargetID )) return SendClientMessage(playerid, COLOR_RED, "* Player Is Not Connected.");
new string[300], srting1[128];
new Float:burnx, Float:burny, Float:burnz; GetPlayerPos(TargetID,burnx, burny, burnz); CreateExplosion(burnx, burny , burnz, 7,10.0);
format(string,sizeof(string),"** EXPLODE: %s (%d) (ADMIN EXPLODE) Has Been EXPLODED By An Admin. (Reason: %s)", targetname,TargetID,reason);
SendClientMessageToAll(COLOR_HOTPINK,string);
format(srting1,sizeof(srting1),"You have exploded %s (%d)", targetname,TargetID);
SendClientMessage(playerid,COLOR_HOTPINK,srting1);
return 1;
}
when i use it , it says the name of someone else but id is fine
Re: Help With getting name -
electrux - 30.03.2014
it is because u are trying to fetch the name of player by id BEFORE knowing the id itself... the GetPlayerName function should be AFTER the sscanf call.
Try this:
Код:
CMD:explode(playerid,params[])
{
if(pInfo[playerid][Adminlevel] < 5) return SendClientMessage(playerid, COLOR_RED, "ERROR_MESSAGE");
new TargetID, reason[20];
new targetname[MAX_PLAYER_NAME];
if(sscanf(params, "us", TargetID, reason)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /explode [id] [reason]");
if(TargetID == INVALID_PLAYER_ID || !IsPlayerConnected(TargetID )) return SendClientMessage(playerid, COLOR_RED, "* Player Is Not Connected.");
GetPlayerName(TargetID, targetname, sizeof(targetname));
new string[300], srting1[128];
new Float:burnx, Float:burny, Float:burnz; GetPlayerPos(TargetID,burnx, burny, burnz); CreateExplosion(burnx, burny , burnz, 7,10.0);
format(string,sizeof(string),"** EXPLODE: %s (%d) (ADMIN EXPLODE) Has Been EXPLODED By An Admin. (Reason: %s)", targetname,TargetID,reason);
SendClientMessageToAll(COLOR_HOTPINK,string);
format(srting1,sizeof(srting1),"You have exploded %s (%d)", targetname,TargetID);
SendClientMessage(playerid,COLOR_HOTPINK,srting1);
return 1;
}
Re: Help With getting name -
AroseKhanNiazi - 30.03.2014
Код:
CMD:jail(playerid,params[]) {
new TargetID;
if(pInfo[playerid][Adminlevel] < 5) return SendClientMessage(playerid, COLOR_RED,""ERROR_MESSAGE"");
new tmp[256], tmp2[256], tmp3[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index), tmp3 = strtok(params,Index);
if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "Usage: /jail [playerid] [minutes] [reason]");
new targetname[MAX_PLAYER_NAME];
GetPlayerName(TargetID,targetname,24);
if(caged[TargetID] == 1) return SCM(playerid,COLOR_RED,"The Player is Caged");
new string[128];
TargetID = strval(tmp);
if(TargetID == INVALID_PLAYER_ID || !IsPlayerConnected(TargetID )) return SendClientMessage(playerid, COLOR_RED, "* Player Is Not Connected.");
if(pInfo[TargetID][Jailed] == 0) {
new jtime = strval(tmp2);
if(jtime == 0) jtime = 9999;
pInfo[TargetID][JailTime] = jtime*1000*60;
JailPlayer(TargetID);
Jail1(TargetID);
SetPlayerInterior(TargetID,10);
SetPlayerPos(TargetID,227.5357,109.9256,999.0156);
pInfo[TargetID][Jailed] = 1;
if(jtime == 9999) {
if(!strlen(params[strlen(tmp2)+1])) format(string,sizeof(string),"** JAIL: %s (%d) (Admin Jail)",targetname,TargetID);
else format(string,sizeof(string),"** JAIL: %s (%d) (Admin Jail) (reason: %s)",targetname,TargetID, params[strlen(tmp)+1] );
} else {
if(!strlen(tmp3)) format(string,sizeof(string),"** JAIL: %s (%d) (Admin Jail) for %d minutes",targetname,TargetID, jtime);
else format(string,sizeof(string),"** JAIL: %s (%d) (Admin Jail) for %d minutes (reason: %s)",targetname,TargetID, jtime, params[strlen(tmp2)+strlen(tmp)+1] );
}
return SendClientMessageToAll(COLOR_HOTPINK,string);
} else return SendClientMessage(playerid, COLOR_RED, "Player is already in jail");
}
same here