12.02.2009, 06:30
how can i do if the player type etc. this: /color yellow or /color trans etc. the player color will change? ;o
#define COLOR_YELLOW 0xFFDD0000 #define COLOR_GREEN 0x00990000 #define COLOR_RED 0x99000000 // etc...
// command time! if (strcmp(cmdtext,"/color",true) == 0) { new params[128]; strmid(params, cmdtext, strfind(cmdtext, " ", true)); // these two lines would do the same as strtok, you can use that if you prefer it! if (!strlen(params)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /color [color]"); if (strcmp(params, "yellow", true) == 0) SetPlayerColor(playerid, COLOR_YELLOW; else if (strcmp(params, "green", true) == 0) SetPlayerColor(playerid, COLOR_GREEN; else if (strcmp(params, "red", true) == 0) SetPlayerColor(playerid, COLOR_GREEN; [....] else SendClientMessage(playerid, COLOR_YELLOW, "What color is that? There's only yellow, green and red in this example"); }
C:\Users\Martin\Desktop\PUTDETHERINTILSA-MP\colorcmds.pwn(3) : error 010: invalid function or declaration C:\Users\Martin\Desktop\PUTDETHERINTILSA-MP\colorcmds.pwn(6) : error 021: symbol already defined: "strmid" C:\Users\Martin\Desktop\PUTDETHERINTILSA-MP\colorcmds.pwn(8) : error 010: invalid function or declaration C:\Users\Martin\Desktop\PUTDETHERINTILSA-MP\colorcmds.pwn(9) : error 010: invalid function or declaration C:\Users\Martin\Desktop\PUTDETHERINTILSA-MP\colorcmds.pwn(11) : error 010: invalid function or declaration C:\Users\Martin\Desktop\PUTDETHERINTILSA-MP\colorcmds.pwn(13) : error 010: invalid function or declaration C:\Users\Martin\Desktop\PUTDETHERINTILSA-MP\colorcmds.pwn(15) : error 010: invalid function or declaration C:\Users\Martin\Desktop\PUTDETHERINTILSA-MP\colorcmds.pwn(17) : error 010: invalid function or declaration C:\Users\Martin\Desktop\PUTDETHERINTILSA-MP\colorcmds.pwn(20) : warning 203: symbol is never used: "params" Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 8 Errors.
public OnPlayerCommamdText(playerid, cmdtext[]) { if (strcmp(cmdtext,"/color",true) == 0) { new params[128]; strmid(params, cmdtext, strfind(cmdtext, " ", true)); // these two lines would do the same as strtok, you can use that if you prefer it! if (!strlen(params)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /color [color]"); if (strcmp(params, "yellow", true) == 0) SetPlayerColor(playerid, COLOR_YELLOW); else if (strcmp(params, "green", true) == 0) SetPlayerColor(playerid, COLOR_GREEN); else if (strcmp(params, "red", true) == 0) SetPlayerColor(playerid, COLOR_RED); else SendClientMessage(playerid, COLOR_YELLOW, "What color is that? There's only yellow, green and red in this example"); return 1; } }
#include <a_samp> public OnPlayerCommandText(playerid,cmdtext[]) { { if (strcmp(cmdtext,"/color",true) == 0) { new params[128]; strmid(params, cmdtext, strfind(cmdtext, " ", true)); { if (!strlen(params)) return SendClientMessage(playerid, 0xFF0000AA, "[USAGE]: /color [YELLOW/GREEN/RED]"); } if (strcmp(params, "yellow", true) == 0) SetPlayerColor(playerid, 0xFFFF00AA); else if (strcmp(params, "green", true) == 0) SetPlayerColor(playerid, 0x33FF33AA); else if (strcmp(params, "red", true) == 0) SetPlayerColor(playerid, 0xFF0000AA); else SendClientMessage(playerid, 0xFF0000AA, "[ERROR]: Invalid color."); return 1; } return 0; }
C:\Users\Martin\Desktop\PUTDETHERINTILSA-MP\colorcmds.pwn(8) : warning 202: number of arguments does not match definition C:\Users\Martin\Desktop\PUTDETHERINTILSA-MP\colorcmds.pwn(25) : error 030: compound statement not closed at the end of file (started at line 4) Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 1 Error.
public OnPlayerCommamdText(playerid, cmdtext[]) { if (strcmp(cmdtext,"/color",true) == 0) { // these two lines would do the same as strtok, you can use that if you prefer it! new params[128]; strmid(params, cmdtext, strfind(cmdtext, " ", true), strlen(params)); if (!strlen(params)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /color [color]"); if (strcmp(params, "yellow", true) == 0) SetPlayerColor(playerid, COLOR_YELLOW); else if (strcmp(params, "green", true) == 0) SetPlayerColor(playerid, COLOR_GREEN); else if (strcmp(params, "red", true) == 0) SetPlayerColor(playerid, COLOR_RED); else SendClientMessage(playerid, COLOR_YELLOW, "What color is that? There's only yellow, green and red in this example"); return 1; } }
#include <a_samp> public OnPlayerCommandText(playerid,cmdtext[]) { if(strcmp(cmdtext, "/color", true) == 0) { new params[128]; strmid(params, cmdtext, strfind(cmdtext, "", true)); { if (!strlen(params)) return SendClientMessage(playerid, 0xFF0000AA, "[USAGE]: /color [YELLOW/GREEN/RED]"); } if (strcmp(params, "yellow", true) == 0) SetPlayerColor(playerid, 0xFFFF00AA); else if (strcmp(params, "green", true) == 0) SetPlayerColor(playerid, 0x33FF33AA); else if (strcmp(params, "red", true) == 0) SetPlayerColor(playerid, 0xFF0000AA); else SendClientMessage(playerid, 0xFF0000AA, "[ERROR]: Invalid color."); return 1; } return 0; }
C:\Users\Martin\Desktop\PUTDETHERINTILSA-MP\colorcmds.pwn(8) : warning 202: number of arguments does not match definition Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 1 Warning.
strmid(params, cmdtext, strfind(cmdtext, "", true));
strmid(params, cmdtext, strfind(cmdtext, "", true), strlen(params));