How do I make this in ZCMD? -
jNkk - 22.12.2012
Hello.
I am intermediate at scripting , so I don't know much, but I found this script.
Код:
dcmd_changecolor(playerid, params[]){
if(IsPlayerInAnyVehicle(playerid))
{
new color1, color2;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /carcolor >color1< >color2<");
color1 = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /carcolor >color1< >color2<");
color2 = strval(tmp);
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
}
else
{
SendClientMessage(playerid,COLOR_ORANGE,"You aren't in any Vehicle!");
}
return 1;
}
How do I make this in ZCMD? I really need it because I kinda like ZCMD better than DCMD...
If i just replace "dcmd_" with "CMD:" i get tons of errors, like:
Код:
C:\Users\Alin\Desktop\SanFierro CNR\gamemodes\sfcnr.pwn(325) : error 017: undefined symbol "tmp"
C:\Users\Alin\Desktop\SanFierro CNR\gamemodes\sfcnr.pwn(325) : error 017: undefined symbol "strtok"
C:\Users\Alin\Desktop\SanFierro CNR\gamemodes\sfcnr.pwn(326) : warning 217: loose indentation
C:\Users\Alin\Desktop\SanFierro CNR\gamemodes\sfcnr.pwn(326) : error 017: undefined symbol "tmp"
C:\Users\Alin\Desktop\SanFierro CNR\gamemodes\sfcnr.pwn(327) : error 017: undefined symbol "tmp"
C:\Users\Alin\Desktop\SanFierro CNR\gamemodes\sfcnr.pwn(328) : error 017: undefined symbol "tmp"
C:\Users\Alin\Desktop\SanFierro CNR\gamemodes\sfcnr.pwn(328) : error 017: undefined symbol "strtok"
C:\Users\Alin\Desktop\SanFierro CNR\gamemodes\sfcnr.pwn(329) : error 017: undefined symbol "tmp"
C:\Users\Alin\Desktop\SanFierro CNR\gamemodes\sfcnr.pwn(330) : error 017: undefined symbol "tmp"
C:\Users\Alin\Desktop\SanFierro CNR\gamemodes\sfcnr.pwn(337) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
8 Errors.
And where can I find this "Strtok" thingy? I heard its outdated but I see many scripts that use it and I can't use them because I can't find it (strtok)
Thank you
Re: How do I make this in ZCMD? -
DaRk_RaiN - 22.12.2012
Hmm, here's how you convert it but make sure you defined everything.
pawn Код:
CMD:changecolor(playerid, params[])
{
new color1, color2;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /carcolor >color1< >color2<");
color1 = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /carcolor >color1< >color2<");
color2 = strval(tmp);
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
}
else
{
SendClientMessage(playerid,COLOR_ORANGE,"You aren't in any Vehicle!");
}
return 1;
}
Re: How do I make this in ZCMD? -
jNkk - 22.12.2012
You're joking right? I even said if I do what you did I get tons of erros.
I basically need someone to make this so I get no errors because I don't know what to do... I am kinda noobish-intermediate as I said..
Thank you
Re: How do I make this in ZCMD? -
DaRk_RaiN - 22.12.2012
Well then go to the defines of this script you took the cmd from and put then put them in your script they'd look something like this
new cmd[256];
new tmp[256];
new idx;
ect..
Re: How do I make this in ZCMD? -
Faisal_khan - 22.12.2012
This is the right code:
pawn Код:
CMD:changecolor(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid))
{
new color1, color2, tmp[128];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /carcolor >color1< >color2<");
color1 = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /carcolor >color1< >color2<");
color2 = strval(tmp);
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
}
else
{
SendClientMessage(playerid,COLOR_ORANGE,"You aren't in any Vehicle!");
}
return 1;
}
Add this in last of your script:
pawn Код:
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;
}
Re: How do I make this in ZCMD? -
jNkk - 22.12.2012
Did this exactly before checking the answers, but somehow got errors. Tried again and only 2 now:
Код:
C:\Users\Alin\Desktop\SanFierro CNR\gamemodes\sfcnr.pwn(327) : error 017: undefined symbol "cmdtext"
C:\Users\Alin\Desktop\SanFierro CNR\gamemodes\sfcnr.pwn(330) : error 017: undefined symbol "cmdtext"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Errors.
Re: How do I make this in ZCMD? -
jNkk - 22.12.2012
By the way, found strtok.ini so all I had to do was #include <strtok> ... now just the two errors left.. Somebody told me how to fix them but I lost the convo
This forum requires that you wait 120 seconds between posts. Please try again in 55 seconds.
This forum requires that you wait 120 seconds between posts. Please try again in 44 seconds
This forum requires that you wait 120 seconds between posts. Please try again in 31 seconds.
This forum requires that you wait 120 seconds between posts. Please try again in 21 seconds.
This forum requires that you wait 120 seconds between posts. Please try again in 11 seconds.
Re: How do I make this in ZCMD? -
Faisal_khan - 22.12.2012
Dafuq! Just know remembered that ZCMD uses sscanf, so you will have to convert it into sscanf+ZCMD.
Re: How do I make this in ZCMD? -
DaRk_RaiN - 22.12.2012
Try to change cmdtext by params.
@Faisal_khan he isn't obligated to use sscanf but i highly recommend that its easier and faster.
Re: How do I make this in ZCMD? -
jNkk - 22.12.2012
Replaced with Params, now the error applies for "idx" .... lol