new crimeArray[600]={"Reckless Driving", "Vehicular Homicide", "vehicular manslaughter", "vehicular assault",
"hit and run", "water eluding", "air eluding"};
stock ReturnSu(text[], playerid)
{
new pos = 0;
while (text[pos] < 0x21) // Strip out leading spaces
{
if (text[pos] == 0) return 0; // No passed text
pos++;
}
// They entered [part of] a name or the id search failed (check names just incase)
new len = strlen(text[pos]);
new count = 0;
new crimeID;
new crime[MAX_PLAYER_NAME];
for (new i = 0; i < sizeof(crimeArray); i++)
{
if (strcmp(crimeArray[i], text[pos], true, len) == 0) // Check segment of name
{
if (len == strlen(text)) // Exact match
{
return i; // Return the exact player on an exact match
}
else // Partial match
{
count++;
crimeID = i;
}
}
}
if (count != 1)
{
if (count)
{
SendClientMessage(playerid, 0xFF0000AA, "Multiple charges found, please narrow search.");
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "No matching charge found.");
}
}
return crimeID; // INVALID_PLAYER_ID for bad return
}
COMMAND:su(playerid, params[])
{
new crimSearch, crimeID;
if(!sscanf(params, "s[64]", crimSearch))
{
crimeID = ReturnSu(crimSearch);
SCM(playerid, RED, crimeArray[crimeID]);
}
else SCM(playerid, YELLOW, "Usage: /su (player id/part of name)");
}
u(playerid, params[])" was set to "playerid". I just need to pass the id of he who called the command to the script, so that the script can send the messages that are part of the stock code itself.
|
Could someone possibly explain why "text[]" has the brackets after it? Does this make the text an array? Like I said, I took this function from the GF script but don't fully understand it yet.
|
COMMAND:su(playerid, params[])
{
new crimSearch, crimeID;
if(!sscanf(params, "s[64]", crimSearch))
{
crimeID = ReturnSu(crimSearch);
SCM(playerid, RED, crimeArray[crimeID]);
}
else SCM(playerid, YELLOW, "Usage: /su (player id/part of name)");
}
COMMAND:su(playerid, params[])
{
new crimSearch[64], crimeID, idx;
if(!sscanf(params, "is[64]", idx, crimSearch))
{
crimeID = ReturnSu(idx, crimSearch);
SCM(playerid, RED, crimeArray[crimeID]);
}
else SCM(playerid, YELLOW, "Usage: /su (player id/part of name) (part of crime name)");
}
/su 5 Homicide