01.06.2010, 18:07
I'm just wondering how can you make a Car Color Command? I've tried searching on the wiki/forums, not luck finding anything similar.
if(!strcmp(cmdtext,"/carcolor",true,9)==0) { new tmp[24],tmp2[24],Index, color1,color2; if(!IsPlayerInAnyVehicle(playerid) return SendClientMessage(playerid,oxffffffaa,"You mst be in car to use this command"); if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid,0xffffffaa,"Usage: /carcolor color1 color2"); tmp=strtok(cmdtext,Index); tmp2=strtok(cmdtext,Index); color1=strval(tmp); color2=strval(tmp2); ChangeVehicleColor(GetPlayerVehicleID(playerid),color1,color2); return 1; }
Originally Posted by DJDhan
Код:
if(!strcmp(cmdtext,"/carcolor",true,9)==0) { new tmp[24],tmp2[24],Index, color1,color2; if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid,0xffffffaa,"Usage: /carcolor color1 color2"); color1=strtok(params,Index); color2=strtok(params,Index); ChangeVehicleColor(GetPlayerVehicleID(playerid),color1,color2); return 1; } |
Originally Posted by DJDhan
Just replace params with cmdtext. Edited again.
|
if(strcmp(cmd, "/carcolor", true) == 0){ if(IsPlayerInAnyVehicle(playerid)) { new color1, color2; tmp = strtok(cmdtext, idx); if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /carcolor >color1< >color2<"); color1 = strval(tmp); tmp = strtok(cmdtext, idx); if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /carcolor >color1< >color2<"); color2 = strval(tmp); ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2); } else { SendClientMessage(playerid,COLOR_RED,"Your Not in any Vehicle!"); } return 1;}
Originally Posted by _Ч§hмf†ҐЧ™_
Not a problem fella.
|
new timer; new secs;
if(!strcmp(cmd,"/countdown,true)) { secs = 5; timer = SetTimer("countdown", 999, 1); return 1;}
forward Countdown(); public Countdown() { if(secs == 0) { GameTextForAll("~r~Go!",1000,3); KillTimer(timer); } else { new string[8]; format(string,sizeof(string),"~R~%d",secs); GameTextForAll(string,1000,3); } secs = secs-1; return 1; }
Originally Posted by _Ч§hмf†ҐЧ™_
Never tryed before, let me go try one, check back here soon.
|
#include <a_samp> 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; } return 0; } stock strtok(const string[], &index) { new length = strlen(string); while ((index < length) && (string[index] <= ' ')) { index++; } new offset = index; new result[20]; while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1))) { result[index - offset] = string[index]; index++; } result[index - offset] = EOS; return result; }
Код:
if(strcmp(cmd, "/carcolor", true) == 0){ if(IsPlayerInAnyVehicle(playerid)) { new color1, color2; tmp = strtok(cmdtext, idx); if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /carcolor >color1< >color2<"); color1 = strval(tmp); tmp = strtok(cmdtext, idx); if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /carcolor >color1< >color2<"); color2 = strval(tmp); ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2); } else { SendClientMessage(playerid,COLOR_RED,"Your Not in any Vehicle!"); } return 1;} |
E:\R5 0.3c Server\gamemodes\SevenStar.pwn(1050) : error 017: undefined symbol "cmd" E:\R5 0.3c Server\gamemodes\SevenStar.pwn(1054) : error 017: undefined symbol "tmp" E:\R5 0.3c Server\gamemodes\SevenStar.pwn(1054) : error 017: undefined symbol "idx" E:\R5 0.3c Server\gamemodes\SevenStar.pwn(1055) : error 017: undefined symbol "tmp" E:\R5 0.3c Server\gamemodes\SevenStar.pwn(1056) : error 017: undefined symbol "tmp" E:\R5 0.3c Server\gamemodes\SevenStar.pwn(1057) : error 017: undefined symbol "tmp" E:\R5 0.3c Server\gamemodes\SevenStar.pwn(1057) : error 017: undefined symbol "idx" E:\R5 0.3c Server\gamemodes\SevenStar.pwn(1058) : error 017: undefined symbol "tmp" E:\R5 0.3c Server\gamemodes\SevenStar.pwn(1059) : error 017: undefined symbol "tmp"