if(!strcmp("/try", cmdtext, true, 5))
{
new getplayer[128];
new str[128];
new str1[128];
GetPlayerName(playerid, getplayer, sizeof(getplayer));
format(str, sizeof(str), "%s Tries to: %s and succeeds", getplayer, str[0]);
format(str1, sizeof(str1), "%s Tries to %s but fails", getplayer, str1[0]);
switch(random(3))
{
case 1:
{
SendClientMessage(playerid, COLOR_PURPLE, str);
}
case 2:
{
SendClientMessage(playerid, COLOR_PURPLE, str1);
}
}
return 1;
}
if(!strcmp("/try", cmdtext, true, 5))
{
new name[25], string[64];
GetPlayerName(playerid, name, 25);
switch(random(3))
{
case 0:
{
format(string, 64, "%s Tries to: %s and succeeds", name);
SendClientMessage(playerid, COLOR_PURPLE, string);
}
case 2:
{
format(string, 64, "%s Tries to %s but fails", name);
SendClientMessage(playerid, COLOR_PURPLE, str1);
}
case 3:
{
format(string, 64, "%s Tries to %s but fails", name);
SendClientMessage(playerid, COLOR_PURPLE, str1);
}
}
return 1;
}
Lol i always thought it was max name 26 (i was adamant) hell knows where i got that from
|
Okay.., It don't let me type an Action? I do /try Test and it says that the command is Unknown?
|
if(strcmp("/try", cmdtext, true, 4) == 0)
{
if(strlen(cmdtext) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Ussage: /try [text]");
{
new name[25], string[64];
GetPlayerName(playerid, name, 25);
switch(random(3))
{
case 0:
{
format(string, 64, "%s Tries to: %s and succeeds", name, cmdtext);
SendClientMessage(playerid, 0xF9B7FFAA, string);
}
case 2:
{
format(string, 64, "%s Tries to %s but fails", name, cmdtext);
SendClientMessage(playerid, 0xF9B7FFAA, string);
}
case 3:
{
format(string, 64, "%s Tries to %s but fails", name, cmdtext);
SendClientMessage(playerid, 0xF9B7FFAA, string);
}
}
}
return 1;
}
no point.. for a cmd like this..
isnull and zcmd is the fastest way i see it |
Again your missing case 1. And random(3) will give 4 cases not 3 (cases 0, 1, 2, 3). If he is comfortable using sscanf there is no problem using that for null checks its not exactly insanely inefficient. Nor is it slow.
|
// With SSCANF
new Cmdstring[30] = "imastringok?testingsomeshit";
public OnGameModeInit()
{
new Tick = GetTickCount();
new sscanfstring[30];
sscanf(Cmdstring, "s[30]", sscanfstring);
switch(random(3))
{
case 0: { printf("1"); }
case 1: { printf("2"); }
case 2: { printf("3"); }
}
printf("%d", GetTickCount()-Tick);
printf("%s", sscanfstring);
return 1;
}
// Without SScanf
new Cmdstring[30] = "imastringok?testingsomeshit";
public OnGameModeInit()
{
new Tick = GetTickCount();
switch(random(3))
{
case 0: { printf("1"); }
case 1: { printf("2"); }
case 2: { printf("3"); }
}
printf("%d", GetTickCount()-Tick);
printf("%s", Cmdstring);
return 1;
}
//SScanf 1-1-0
//W/O SScanf 0-1-1