16.06.2012, 15:01
Yea, and what you just did takes a lot of time for every command, and creates a extra string for every command. Who's the smart one now?
Good tutorial but... you can remove the '_' from the name without strreplace:
-False , you do NOT need it , but you can use it , another way of replacing, without creating any stocks/functions is: pawn Code:
I'm just saying that creating stocks when they are not needed is not very smart.. but anyways 10/10 amazing tutorial. |
When I type /shout and my message its send me the message "USAGE: /(s)hout [message]..
|
CMD:shout(playerid, params[])
{
if(isnull(params)) {
return SendClientMessage(playerid, -1, "USAGE: /(s)hout [message]");
}
else {
new string[128];
format(string, sizeof(string), "%s shouts: %s!", GetName(playerid), params);
ProxDetector(50.0, playerid, string, -1);
}
return 1;
}
How do you use strfind to replace the underscore?
pawn Code:
|
CMD:do(playerid, params[]) { new string[128], action[100]; if(sscanf(params, "s[100]", action)) { SendClientMessage(playerid, -1, "USAGE: /do [action]"); return 1; } else { format(string, sizeof(string), "* %s (( %s ))", params, GetName(playerid)); ProxDetector(30, playerid, string, COLOR_PURPLE); } return 1; }
C:\Users\Feleren\Desktop\SAMP\pawno\include\Dini.inc(239) : warning 219: local variable "string" shadows a variable at a preceding level C:\Users\Feleren\Desktop\Other Servers for SAMP\ProjectUltimate\gamemodes\PUv1.3.pwn(74) : warning 217: loose indentation C:\Users\Feleren\Desktop\Other Servers for SAMP\ProjectUltimate\gamemodes\PUv1.3.pwn(85) : warning 217: loose indentation C:\Users\Feleren\Desktop\Other Servers for SAMP\ProjectUltimate\gamemodes\PUv1.3.pwn(105) : warning 217: loose indentation C:\Users\Feleren\Desktop\Other Servers for SAMP\ProjectUltimate\gamemodes\PUv1.3.pwn(136) : warning 219: local variable "string" shadows a variable at a preceding level C:\Users\Feleren\Desktop\Other Servers for SAMP\ProjectUltimate\gamemodes\PUv1.3.pwn(149) : error 021: symbol already defined: "GetPlayerName" C:\Users\Feleren\Desktop\Other Servers for SAMP\ProjectUltimate\gamemodes\PUv1.3.pwn(150) : error 021: symbol already defined: "strreplace" C:\Users\Feleren\Desktop\Other Servers for SAMP\ProjectUltimate\gamemodes\PUv1.3.pwn(156) : warning 219: local variable "name" shadows a variable at a preceding level C:\Users\Feleren\Desktop\Other Servers for SAMP\ProjectUltimate\gamemodes\PUv1.3.pwn(175) : warning 219: local variable "string" shadows a variable at a preceding level C:\Users\Feleren\Desktop\Other Servers for SAMP\ProjectUltimate\gamemodes\PUv1.3.pwn(179) : error 017: undefined symbol "foreach" C:\Users\Feleren\Desktop\Other Servers for SAMP\ProjectUltimate\gamemodes\PUv1.3.pwn(181) : error 017: undefined symbol "i" C:\Users\Feleren\Desktop\Other Servers for SAMP\ProjectUltimate\gamemodes\PUv1.3.pwn(183) : error 017: undefined symbol "i" C:\Users\Feleren\Desktop\Other Servers for SAMP\ProjectUltimate\gamemodes\PUv1.3.pwn(195) : error 021: symbol already defined: "format" C:\Users\Feleren\Desktop\Other Servers for SAMP\ProjectUltimate\gamemodes\PUv1.3.pwn(197) : error 010: invalid function or declaration C:\Users\Feleren\Desktop\Other Servers for SAMP\ProjectUltimate\gamemodes\PUv1.3.pwn(197) : error 021: symbol already defined: "ProxDetector" C:\Users\Feleren\Desktop\Other Servers for SAMP\ProjectUltimate\gamemodes\PUv1.3.pwn(197) : warning 215: expression has no effect C:\Users\Feleren\Desktop\Other Servers for SAMP\ProjectUltimate\gamemodes\PUv1.3.pwn(197) : error 001: expected token: ";", but found ")" C:\Users\Feleren\Desktop\Other Servers for SAMP\ProjectUltimate\gamemodes\PUv1.3.pwn(197) : fatal error 107: too many error messages on one line Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 10 Errors.
stock strreplace(string[], find, replace)
{
for(new i=0; string[i]; i++)
{
if(string[i] == find)
{
string[i] = replace;
}
}
}
stock GetName(playerid)
{
new
name[24];
GetPlayerName(playerid, name, sizeof(name));
strreplace(name, '_', ' ');
return name;
}