25.10.2011, 11:42
I got a serious problem yesterday with the gamemode. I change the messages on the /goto command and when I went to test it in every command appears text "You have teleported to Harry_Potter" (Bot id 0) and I was teleported to the bot. I delete the /goto command and the that problem still was at /carcolor command. I remove /carcolor command too and all works fine. But I want two these commands.Here is OnPlayerCommandText
This is only with /carcolor. Any command I wrote it says "USAGE: /carcolor [color1] [color2]"
And the stock
Please help me
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], tmp[256], idx;
if(strcmp(cmd, "/carcolor", true) == 0)
{
new color1, color2;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USAGE: /carcolor [color1] [color2]");
color1 = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USAGE: /carcolor [color1] [color2]");
color2 = strval(tmp);
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
return 1;
}
if (strcmp(cmdtext, "/tgoto", true, 10) == 0) {
ShowPlayerDialog(playerid, 15, DIALOG_STYLE_LIST, "{FFFFFF}Toggle Goto", "{00FF00}Enable\n{FF0000}Disable", "Select", "Cancel");
return 1;
}
if (strcmp("/infernus", cmdtext, true, 10) == 0) {
new vehicleid;
new Float:X,Float:Y,Float:Z,Float:Angle;
GetPlayerPos(playerid,X,Y,Z);
GetPlayerFacingAngle(playerid,Angle);
GetPlayerVehicleID(playerid);
vehicleid = vehicleid = CreateVehicle(411,X,Y,Z,Angle,-1,-1,600);
PutPlayerInVehicle(playerid, vehicleid, 0);
return 1;
}
//More cars
if(!strcmp(cmdtext,"/SavePOS", true)) {
GetPlayerPos(playerid, X_P[playerid],Y_P[playerid],Z_P[playerid]);
return true;
}
if(!strcmp(cmdtext,"/LoadPOS", true)) {
if (GetPlayerState(playerid)==PLAYER_STATE_DRIVER)SetVehiclePos(GetPlayerVehicleID(playerid), X_P[playerid],Y_P[playerid],Z_P[playerid]);
else SetPlayerPos(playerid, X_P[playerid],Y_P[playerid],Z_P[playerid]);
ResetPlayerWeapons(playerid);
return true;
}
if (strcmp(cmdtext, "/changeskin", true, 11) == 0) {
new string[128], skinid;
if(!cmdtext[11]) return SendClientMessage(playerid, 0x33AA33AA, "Usage: /changeskin [skinid]");
skinid = strval(cmdtext[12]);
switch(skinid) {
case 3, 4, 5, 6, 8, 42, 65, 74, 86, 119, 149, 208, 268, 273, 289: { return SendClientMessage(playerid, 0x33AA33AA, "Error: invalid skin ID!"); }
default:
{
SetPlayerSkin(playerid, skinid);
format(string, sizeof(string), "You have successfully changed your skin to %d", skinid);
SendClientMessage(playerid, 0x33AA33AA, string);
}
}
return 1;
}
if (strcmp(cmdtext, "/ammu1", true) == 0) {
RemovePlayerFromVehicle(playerid);
SetPlayerPos(playerid,2336.6277,61.5870,25.9851);
GameTextForPlayer(playerid,"",4000,6);
return 1;
}
//More Teleports
if (strcmp(cmdtext, "/neon", true)==0) {
ShowPlayerDialog(playerid, 8899, DIALOG_STYLE_LIST, "Pick Neon Color", "Blue\nRed\nGreen\nWhite\nPink\nYellow\nRemove All Neon", "Select", "Cancel");
return 1;
}
else return SendClientMessage(playerid, COLOR_RED, "ERROR: Unknown command. See all the commands with /cmds");
}
And the stock
pawn Код:
// Written by DracoBlue.
stock strtok(const string[], &index,seperator=' ')
{
new length = strlen(string);
new offset = index;
new result[MAX_STRING];
while ((index < length) && (string[index] != seperator) && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
if ((index < length) && (string[index] == seperator))
{
index++;
}
return result;
}