if(strcmp(cmd, "/accent", true) == 0) { new length = strlen(cmdtext); while ((idx < length) && (cmdtext[idx] <= ' ')) { idx++; } new offset = idx; new result[128]; while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) { result[idx - offset] = cmdtext[idx]; idx++; } result[idx - offset] = EOS; if(!strlen(result)) { SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /accent [accentid] (Type /accents for a list of accents)"); return 1; } new chooseaccent; chooseaccent = strval(tmp); if(chooseaccent == 0) { GameTextForPlayer(playerid, "Accent changed to English", 5000, 5); accent[playerid] = 0; return 1; } else if(chooseaccent == 1) { GameTextForPlayer(playerid, "Accent changed to Russian", 5000, 5); accent[playerid] = 1; return 1; } else if(chooseaccent == 2) { GameTextForPlayer(playerid, "Accent changed to Italian", 5000, 5); accent[playerid] = 2; return 1; } else if(chooseaccent == 3) { GameTextForPlayer(playerid, "Accent changed to Gangster", 5000, 5); accent[playerid] = 3; return 1; } else if(chooseaccent == 4) { GameTextForPlayer(playerid, "Accent changed to French", 5000, 5); accent[playerid] = 4; return 1; } else if(chooseaccent == 5) { GameTextForPlayer(playerid, "Accent changed to Japanese", 5000, 5); accent[playerid] = 5; return 1; } else if(chooseaccent == 6) { GameTextForPlayer(playerid, "Accent changed to Korean", 5000, 5); accent[playerid] = 6; return 1; } else if(chooseaccent == 7) { GameTextForPlayer(playerid, "Accent changed to Chinese", 5000, 5); accent[playerid] = 7; return 1; } else { SendClientMessage(playerid, COLOR_RED, "That isn't a valid accent ID!"); return 1; } }
Originally Posted by Antonio (dominationrp.netii.net)
So, im trying to create an accents section for my script. Im basicly done everything but I cant quite grasp the whole strval(tmp) stuff...
What Im trying to do is.. for example you type /accent 2 it would switch you to Italian (in my code) but it always goes to english... any help? Код:
if(strcmp(cmd, "/accent", true) == 0) { new length = strlen(cmdtext); while ((idx < length) && (cmdtext[idx] <= ' ')) { idx++; } new offset = idx; new result[128]; while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) { result[idx - offset] = cmdtext[idx]; idx++; } result[idx - offset] = EOS; if(!strlen(result)) { SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /accent [accentid] (Type /accents for a list of accents)"); return 1; } new chooseaccent; chooseaccent = strval(tmp); if(chooseaccent == 0) { GameTextForPlayer(playerid, "Accent changed to English", 5000, 5); accent[playerid] = 0; return 1; } else if(chooseaccent == 1) { GameTextForPlayer(playerid, "Accent changed to Russian", 5000, 5); accent[playerid] = 1; return 1; } else if(chooseaccent == 2) { GameTextForPlayer(playerid, "Accent changed to Italian", 5000, 5); accent[playerid] = 2; return 1; } else if(chooseaccent == 3) { GameTextForPlayer(playerid, "Accent changed to Gangster", 5000, 5); accent[playerid] = 3; return 1; } else if(chooseaccent == 4) { GameTextForPlayer(playerid, "Accent changed to French", 5000, 5); accent[playerid] = 4; return 1; } else if(chooseaccent == 5) { GameTextForPlayer(playerid, "Accent changed to Japanese", 5000, 5); accent[playerid] = 5; return 1; } else if(chooseaccent == 6) { GameTextForPlayer(playerid, "Accent changed to Korean", 5000, 5); accent[playerid] = 6; return 1; } else if(chooseaccent == 7) { GameTextForPlayer(playerid, "Accent changed to Chinese", 5000, 5); accent[playerid] = 7; return 1; } else { SendClientMessage(playerid, COLOR_RED, "That isn't a valid accent ID!"); return 1; } } |
COMMAND:accent( playerid, params[] )
{
// For multiple parameters, use sscanf. But we're only going to be parsing one.
switch( strval( params ) ) // Use switch statements where possible for integers.
{
case 1:
{
accent[ playerid ] = 1;
SendClientMessage( playerid, WHITE, "You're now speaking in Russian" );
}
case 2:
{
accent[ playerid ] = 2;
SendClientMessage( playerid, WHITE, "You're now speaking in Italian" );
}
case 3:
{
accent[ playerid ] = 3;
SendClientMessage( playerid, WHITE, "You're now speaking in Gangster" );
}
case 4:
{
accent[ playerid ] = 4;
SendClientMessage( playerid, WHITE, "You're now speaking in French" );
}
case 5:
{
accent[ playerid ] = 5;
SendClientMessage( playerid, WHITE, "You're now speaking in Japanese" );
}
case 6:
{
accent[ playerid ] = 6;
SendClientMessage( playerid, WHITE, "You're now speaking in Korean" );
}
case 7:
{
accent[ playerid ] = 7;
SendClientMessage( playerid, WHITE, "You're now speaking in Chinese" );
}
default:
{
SendClientMessage( playerid, WHITE, "Invalid accent ID (use /accents)." );
}
}
return 1;
}
Originally Posted by Antonio (dominationrp.netii.net)
Its nice, but I prefer to stay with the old kind of scripting.
|
Originally Posted by Antonio (dominationrp.netii.net)
Its nice, but I prefer to stay with the old kind of scripting.
|