ZCMD if string is empty help! - 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)
+--- Thread: ZCMD if string is empty help! (
/showthread.php?tid=282201)
ZCMD if string is empty help! -
brett7 - 09.09.2011
Hi, I started making an admin script using ZCMD. It works fine but I wanted it so that if you typed in "/akill 0 test" it will print out you have been killed for a reason. But if the string "[reason]" was left blank it would print out " [No reason specified]". However I keep getting this error "bAdmin2.pwn(406) : error 033: array must be indexed (variable "str2")" And its probably something quite simple :/
Код:
CMD:akill(playerid, params[])
{
if(Level[playerid] < 1) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: you are not level 1!");
new str[256], str2[256], id, AdminName[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
if(sscanf(params, "uS", id, str2))
{
SendClientMessage(playerid, 0xFF0000FF, "Usage: /akill [id] [reason]");
return 1;
}
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: Player not connected");
if(IsPlayerConnected(id))
{
GetPlayerName(playerid, AdminName, sizeof(AdminName));
GetPlayerName(id, PlayerName, sizeof(PlayerName));
SetPlayerHealth(id, 0);
PlayCrimeReportForPlayer(id, id, 4);
if(str2 == NULL){ // LINE 406
format(str, sizeof(str), "Administrator %s has killed %s for: [No reason specified]", AdminName, PlayerName);
SendClientMessage(id, orange, str);
}
else
{
format(str, sizeof(str), "Administrator %s has killed %s for: %s", AdminName, PlayerName, str2);
SendClientMessage(id, orange, str);
}
}
return 1;
}
Re: ZCMD if string is empty help! -
[HiC]TheKiller - 09.09.2011
You cannot get a string that has multiple cells and compare it to something that would use one cell. Do this
or
Re: ZCMD if string is empty help! -
brett7 - 10.09.2011
Thanks works great!
Re: ZCMD if string is empty help! -
0_o - 10.09.2011
Why Don't You Simply Use STRCMP ?
Re: ZCMD if string is empty help! -
[HiC]TheKiller - 10.09.2011
Quote:
Originally Posted by 0_o
Why Don't You Simply Use STRCMP ?
|
He was finding if the string is null, not comparing it to a string.
Re: ZCMD if string is empty help! -
Mean - 10.09.2011
Quote:
Originally Posted by 0_o
Why Don't You Simply Use STRCMP ?
|
Why Don't You Stop Typing Like This? Tarded IMO.
On topic: using isnull is easier than comparing if the string is empty with strcmp...