How do I convert this to zcmd?
#1

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
Reply
#2

"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.
Reply
#3

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
Reply
#4

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.
Reply
#5

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

Anyone?
Reply
#7

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.
Reply
#8

Just use sscanf.
Reply
#9

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
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)