hi im new to scripting and i need help
#1

hi im new to this im picking it up quite fast if you could please show me how to make an /arrest command i could make all the others thx it just a standard script nothing special besides the strok[/language lol i did this lmao
public OnPlayerCommmandText(playerid, cmdtext[])

if(strcmp("/Heal", cmdtext, true, 10) == TEAM_MEDIC)

{
SetPlayerHealth(playerid,100);
GivePlayerMoney(playerid,1000); // THis is for the payment
return 1;
}

if(strcmp("/arrest", cmdtext, true, 10) == TEAM_COP)
{
SendClientMessage(playerid,COLOR_ORANGE,"You Have Been Arrested");
SetPlayerPos(playerid,198.0301, 161.8855, 1003.0234);
GivePlayerMoney(playerid,5000); // THis is for the payment
return 1;
}
else if(strcmp("/ticket", cmdtext, true, 10) == TEAM_COP)
{
SendClientMessage(playerid,COLOR_YELLOW,"You Have Been given a ticket type /pay or be arrested");
GivePlayerMoney(playerid,500); // THis is for the payment
return 1;
}
return 0;
}
as you could imagine yeah lmao no where near that was just a guestimate i only started scripting yesterday so id say not 2 bad of an attempt
Reply
#2

Welcome to the world of scripting.

Firstly, you started off pretty good though you are doing something wrong. The team check should be IN the command and not in the if-statement.
Secondly, even because you are just starting, I would recommend learning DCMD and SSCANF which is way more easier than STRTOK. Because you are starting, I wouldn't go through all the trouble learning strtok and then later on going to dcmd which will take a hell of a lot of time.
Reply
#3

Quote:
Originally Posted by [NT
mamoru ]
Welcome to the world of scripting.

Firstly, you started off pretty good though you are doing something wrong. The team check should be IN the command and not in the if-statement.
Secondly, even because you are just starting, I would recommend learning DCMD and SSCANF which is way more easier than STRTOK. Because you are starting, I wouldn't go through all the trouble learning strtok and then later on going to dcmd which will take a hell of a lot of time.
Thanks buddy ill look into that now. And a big thanks goes out to wiki for there awesome noob help and for all you other noob's wanting same thing you can find it here https://sampwiki.blast.hk/wiki/Dcmd
Reply
#4

Quote:
Originally Posted by madmatty
Quote:
Originally Posted by [NT
mamoru ]
Welcome to the world of scripting.

Firstly, you started off pretty good though you are doing something wrong. The team check should be IN the command and not in the if-statement.
Secondly, even because you are just starting, I would recommend learning DCMD and SSCANF which is way more easier than STRTOK. Because you are starting, I wouldn't go through all the trouble learning strtok and then later on going to dcmd which will take a hell of a lot of time.
Thanks buddy ill look into that now. And a big thanks goes out to wiki for there awesome noob help and for all you other noob's wanting same thing you can find it here https://sampwiki.blast.hk/wiki/Dcmd
i like it thanks just 1 more ? and i can crack on
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(heal, 4, cmdtext);
return 0;
}

dcmd_heal(playerid, params[])
{
if (strlen(params))
{
id = strval(params);
if (IsPlayerConnected(id))
{
SetPlayerHealth(id, 100.0);
SendClientMessage(id, 0x00FF00AA, "You have been healed");
SendClientMessage(playerid, 0x00FF00AA, "Player healed");
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "Player not found");
}
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/heal <playerid>\"");
}
return 1;
}
thats a heal code how do i set it to TEAM_MEDIC would it be something like dcmd(heal, 4, cmdtext); == TEAM_MEDIC

C:\Documents and Settings\matt\Desktop\SAMP LEARNING\gamemodes\learning.pwn(464) : error 055: start of function body without function header
C:\Documents and Settings\matt\Desktop\SAMP LEARNING\gamemodes\learning.pwn(465) : error 010: invalid function or declaration
C:\Documents and Settings\matt\Desktop\SAMP LEARNING\gamemodes\learning.pwn(466) : error 010: invalid function or declaration
C:\Documents and Settings\matt\Desktop\SAMP LEARNING\gamemodes\learning.pwn(826) : warning 203: symbol is never used: "dcmd_heal"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Reply
#5

Did you defined dcmd?
http://forum.sa-mp.com/index.php?topic=70925.0
Reply
#6

Quote:
Originally Posted by Don Correlli
C:\Documents and Settings\matt\Desktop\SAMP LEARNING\gamemodes\learning.pwn(406) : error 017: undefined symbol "MAX_STRING"
C:\Documents and Settings\matt\Desktop\SAMP LEARNING\gamemodes\learning.pwn(406) : error 009: invalid array size (negative, zero or out of bounds)
C:\Documents and Settings\matt\Desktop\SAMP LEARNING\gamemodes\learning.pwn(406) : error 036: empty statement
C:\Documents and Settings\matt\Desktop\SAMP LEARNING\gamemodes\learning.pwn(406) : fatal error 107: too many error messages on one line
line 406 =
public OnPlayerCommandText(playerid, cmdtext[])
{
405- new idx;
406-new cmd[MAX_STRING];
407-new tmp[MAX_STRING];
408 cmd = strtok(cmdtext, idx);
lol sorry yeah i have defined dcmd #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
Reply
#7

pawn Код:
#define MAX_STRING 128
Reply
#8

Quote:
Originally Posted by Don Correlli
pawn Код:
#define MAX_STRING 128
C:\Documents and Settings\matt\Desktop\SAMP LEARNING\gamemodes\learning.pwn(410) : error 017: undefined symbol "text"
C:\Documents and Settings\matt\Desktop\SAMP LEARNING\gamemodes\learning.pwn(413) : warning 217: loose indentation
C:\Documents and Settings\matt\Desktop\SAMP LEARNING\gamemodes\learning.pwn(409) : warning 203: symbol is never used: "idx"
C:\Documents and Settings\matt\Desktop\SAMP LEARNING\gamemodes\learning.pwn(40 : warning 204: symbol is assigned a value that is never used: "tmp"
C:\Documents and Settings\matt\Desktop\SAMP LEARNING\gamemodes\learning.pwn(408 -- 430) : warning 209: function "OnPlayerCommandText" should return a value
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[MAX_STRING];
new tmp[MAX_STRING];
new idx;
cmd=strtok(text,idx);


if (strcmp("/help", cmdtext, true, 10) == 0)
{
SendClientMessage(playerid,COLOR_YELLOW,"welcome to NWO number 1 cops and robbers");
SendClientMessage(playerid,COLOR_YELLOW,"/commands to see full list of commands");
SendClientMessage(playerid,COLOR_YELLOW,"/serverinfo to see full admin list and server host");
return 1;
}

if (strcmp("/commands", cmdtext, true, 10) == 0)

{
SendClientMessage(playerid,COLOR_YELLOW,"/police to see full list of police commands");
SendClientMessage(playerid,COLOR_YELLOW,"/rob to see full list of rob commands");
SendClientMessage(playerid,COLOR_YELLOW,"/medic to see full list of medic commands");
return 1;
}

}
i deleted all the other like /arrest i mad and that coz it was bringing more errors up but once i get this sorted the /heal command should be sorted aswell
Reply
#9

Quote:
Originally Posted by madmatty
Quote:
Originally Posted by Don Correlli
pawn Код:
#define MAX_STRING 128
C:\Documents and Settings\matt\Desktop\SAMP LEARNING\gamemodes\learning.pwn(410) : error 017: undefined symbol "text"
C:\Documents and Settings\matt\Desktop\SAMP LEARNING\gamemodes\learning.pwn(413) : warning 217: loose indentation
C:\Documents and Settings\matt\Desktop\SAMP LEARNING\gamemodes\learning.pwn(409) : warning 203: symbol is never used: "idx"
C:\Documents and Settings\matt\Desktop\SAMP LEARNING\gamemodes\learning.pwn(40 : warning 204: symbol is assigned a value that is never used: "tmp"
C:\Documents and Settings\matt\Desktop\SAMP LEARNING\gamemodes\learning.pwn(408 -- 430) : warning 209: function "OnPlayerCommandText" should return a value
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[MAX_STRING];
new tmp[MAX_STRING];
new idx;
cmd=strtok(text,idx);


if (strcmp("/help", cmdtext, true, 10) == 0)
{
SendClientMessage(playerid,COLOR_YELLOW,"welcome to NWO number 1 cops and robbers");
SendClientMessage(playerid,COLOR_YELLOW,"/commands to see full list of commands");
SendClientMessage(playerid,COLOR_YELLOW,"/serverinfo to see full admin list and server host");
return 1;
}

if (strcmp("/commands", cmdtext, true, 10) == 0)

{
SendClientMessage(playerid,COLOR_YELLOW,"/police to see full list of police commands");
SendClientMessage(playerid,COLOR_YELLOW,"/rob to see full list of rob commands");
SendClientMessage(playerid,COLOR_YELLOW,"/medic to see full list of medic commands");
return 1;
}

}
i deleted all the other like /arrest i mad and that coz it was bringing more errors up but once i get this sorted the /heal command should be sorted aswell
So all together for dcmd i got
#define MAX_STRING 128
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[MAX_STRING];
new tmp[MAX_STRING];
new idx;
cmd=strtok(text,idx);
stock sscanf(string[], format[], {Float,_}:...)
and the rest of the script that comes with stock sscanf work ok
i got a better solution if u know of a standard cops and robbers script that will help me will u please let me know
so i can look on how the basics work i have 1 but it just a tdm cops and robbers wi no cop commands or nothing
Reply
#10

You don't need this:

Код:
new cmd[MAX_STRING];
new tmp[MAX_STRING];
new idx;
cmd=strtok(text,idx);
if you use only "/help" and "/commands"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)