SA-MP Forums Archive
How do I convert this to zcmd? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How do I convert this to zcmd? (/showthread.php?tid=333588)



How do I convert this to zcmd? - TheMightyEddy - 12.04.2012

pawn Код:
CMD:kidnap(playerid, params[])
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFF0000, "You must be in a vehicle to kidnap someone!");
    new KidnapID = strval(strtok(cmd, idx));
    if(!IsPlayerConnected(KidnapID) || IsNumeric(params)) return SendClientMessage(playerid, 0xFF0000, "That's an invalid ID.");
    if(!IsPlayerInVehicle(GetPlayerVehicleID(playerid))) return SendClientMessage(playerid, 0xFF0000, "That player isn't in your car.");
    if(random(10) == 1)
    new PName[MAX_PLAYER_NAME];
    new KidnapString[40];
    {
        SendClientMessage(playerid, 0xFFFF00, "The kidnap was successful.");
        GetPlayerName(playerid, PName, sizeof(PName));
        format(KidnapString, sizeof(KidnapString), "%s has kidnapped you!", PName);
        SendClientMessage(KidnapID, 0xFF0000, KidnapString);
    }
    else
    {
        GetPlayerName(KidnapID, PName, sizeof(PName));
        format(KidnapString, sizeof(KidnapString), The kidnap failed and %s noticed you tried to kidnap him!", PName);
        SendClientMessage(KidnapID, 0xFF0000, KidnapString);
        GetPlayerName(playerid, PName, sizeof(PName));
        format(KidnapString, sizeof(KidnapString), "
%s has attempted to kidnap you!", PName);
        SendClientMessage(KidnapID, 0xFF0000, KidnapString);
    }
    return 1;
}
I'm stuck. Please help? +REP


Re: How do I convert this to zcmd? - ReneG - 12.04.2012

"cmd" or "cmdtext" is only valid in OnPlayerCommandText. ZCMD is not in that callback, and the command uses "params" instead.

Read this thread to see how ZCMD works.
https://sampforum.blast.hk/showthread.php?tid=91354
And here is the sscanf plugin.
https://sampforum.blast.hk/showthread.php?tid=120356

****** tutorials if you're stuck. You have to help yourself before posting.


Re: How do I convert this to zcmd? - TheMightyEddy - 12.04.2012

Okay well here is what I get:
Код:
C:\Users\Edward\Desktop\CnR1.1\gamemodes\freeroam.pwn(8903) : error 017: undefined symbol "cmd"
C:\Users\Edward\Desktop\CnR1.1\gamemodes\freeroam.pwn(8904) : error 017: undefined symbol "IsNumeric"
C:\Users\Edward\Desktop\CnR1.1\gamemodes\freeroam.pwn(8905) : warning 202: number of arguments does not match definition
C:\Users\Edward\Desktop\CnR1.1\gamemodes\freeroam.pwn(8907) : error 003: declaration of a local variable must appear in a compound block
C:\Users\Edward\Desktop\CnR1.1\gamemodes\freeroam.pwn(8907) : error 017: undefined symbol "PName"
C:\Users\Edward\Desktop\CnR1.1\gamemodes\freeroam.pwn(8907) : warning 215: expression has no effect
C:\Users\Edward\Desktop\CnR1.1\gamemodes\freeroam.pwn(8907) : error 001: expected token: ";", but found "]"
C:\Users\Edward\Desktop\CnR1.1\gamemodes\freeroam.pwn(8907) : fatal error 107: too many error messages on one line



Re: How do I convert this to zcmd? - ReneG - 12.04.2012

You're not even asking how to do it. You just want code. It puzzles me why you are so clueless on sa-mp scripting, and yet you try to tackle commands like this. Learn the basics first, damn.


Re: How do I convert this to zcmd? - TheMightyEddy - 12.04.2012

Do you even understand me? I'm obviously asking how to fix it and what I'm doing wrong.


Re: How do I convert this to zcmd? - TheMightyEddy - 12.04.2012

Anyone?


Re: How do I convert this to zcmd? - ReneG - 12.04.2012

Quote:
Originally Posted by TheMightyEddy
Посмотреть сообщение
Do you even understand me? I'm obviously asking how to fix it and what I'm doing wrong.


Quote:

"cmd" or "cmdtext" is only valid in OnPlayerCommandText. ZCMD is not in that callback, and the command uses "params" instead.

^^ That is what you did wrong, and that is how to fix it. It wouldn't hurt to read the darn ZCMD thread.


Re: How do I convert this to zcmd? - Shetch - 12.04.2012

Just use sscanf.


Re: How do I convert this to zcmd? - Shetch - 12.04.2012

Here you go:

Код:
CMD:kidnap(playerid, params[])
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFF0000, "You must be in a vehicle to kidnap someone!");
    new KidnapID, PName[MAX_PLAYER_NAME], KidnapString[40];
    if(sscanf(params,"u", KidnapID)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /kidnap [ID]");
    if(!IsPlayerConnected(KidnapID) || IsNumeric(params)) return SendClientMessage(playerid, 0xFF0000, "That's an invalid ID.");
    if(!IsPlayerInVehicle(playerid, GetPlayerVehicleID(playerid))) return SendClientMessage(playerid, 0xFF0000, "That player isn't in your car.");
    if(random(10) == 1)
    {
        SendClientMessage(playerid, 0xFFFF00, "The kidnap was successful.");
        GetPlayerName(playerid, PName, sizeof(PName));
        format(KidnapString, sizeof(KidnapString), "%s has kidnapped you!", PName);
        SendClientMessage(KidnapID, 0xFF0000, KidnapString);
    }
    else
    {
        GetPlayerName(KidnapID, PName, sizeof(PName));
        format(KidnapString, sizeof(KidnapString), "The kidnap failed and %s noticed you tried to kidnap him!", PName);
        SendClientMessage(KidnapID, 0xFF0000, KidnapString);
        GetPlayerName(playerid, PName, sizeof(PName));
        format(KidnapString, sizeof(KidnapString), "%s has attempted to kidnap you!", PName);
        SendClientMessage(KidnapID, 0xFF0000, KidnapString);
    }
    return 1;
}
http://forum.sa-mp.com/showthread.ph...ghlight=sscanf


Re: How do I convert this to zcmd? - TheMightyEddy - 12.04.2012

Thanks but it gives me this error:
Код:
error 017: undefined symbol "IsNumeric"
EDIT: Nevermind I got it! just changd IsNumeric to isNumeric.