what's wrong with this command
#1

pawn Код:
CMD:givedrugs(playerid, params[])
{
    if(gTeam[playerid] == DRUG)
    {
        new id, drug[100], ammount;
        if(sscanf(params,"us[100]i",id,drug,ammount)) return SendClientMessage(playerid, -1, "USAGE: /givedrugs <id/name> <drugname> <grams>  - drug names: weed & heroin");
        if GetPlayerWeed(playerid) < ammount) return SendClientMessage(playerid, -1, "You do not have that much grams!");
        if(drug == weed) { GivePlayerWeed(id, ammount); }
        if(drug == heroin) { GivePlayerHeroin(id, ammount); }
        return 1;
    }
    else if(gTeam[playerid] != DRUG)
    {
        SendClientMessage(playerid, -1, "You are not a drug dealer");
        return 1;
    }
    return 1;
}
Reply
#2

How about before you expect people to fix things for you, tell them what is wrong.

I think you mean you want to know why it isn't working when you type in the drugname.

Try this:

pawn Код:
CMD:givedrugs(playerid, params[])
{
    if(gTeam[playerid] == DRUG)
    {
        new id, drug[100], ammount;
        if(sscanf(params,"us[100]i",id,drug,ammount)) return SendClientMessage(playerid, -1, "USAGE: /givedrugs <id/name> <drugname> <grams>  - drug names: weed & heroin");
        if GetPlayerWeed(playerid) < ammount) return SendClientMessage(playerid, -1, "You do not have that much grams!");
        if(!strcmp(drug, "weed", true)) { GivePlayerWeed(id, ammount); }
        if(!strcmp(drug, "heroin", true)) { GivePlayerHeroin(id, ammount); }
        return 1;
    }
    else if(gTeam[playerid] != DRUG)
    {
        SendClientMessage(playerid, -1, "You are not a drug dealer");
        return 1;
    }
    return 1;
}
You cannot compare strings like this:

pawn Код:
drugname == weed
and if it was possible, they would probably make it like this: considering it is writing weed is a variable, not a string.

pawn Код:
drugname == "weed" // This doesn't work either, fyi
Reply
#3

Sorry ive just woken up and not thinking good yet i forgot to post that i had errors with it
Код:
C:\Users\iphone\Desktop\Pawn Scripting\gamemodes\Sfcnr.pwn(2435) : error 001: expected token: "*then", but found ")"
C:\Users\iphone\Desktop\Pawn Scripting\gamemodes\Sfcnr.pwn(2435) : error 029: invalid expression, assumed zero
C:\Users\iphone\Desktop\Pawn Scripting\gamemodes\Sfcnr.pwn(2435) : warning 215: expression has no effect
C:\Users\iphone\Desktop\Pawn Scripting\gamemodes\Sfcnr.pwn(2435) : error 001: expected token: ";", but found "return"
C:\Users\iphone\Desktop\Pawn Scripting\gamemodes\Sfcnr.pwn(2435) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
sooo sorry lol you can tell i just woken up im never like this :P

pawn Код:
if GetPlayerWeed(playerid) < ammount) return SendClientMessage(playerid, -1, "You do not have that much grams!");
all errors are on this line
Reply
#4

If those are new errors, show what lines errors are EVERY time, scripters don't want to search for it themselves.

If they aren't, tell me if my script worked.
Reply
#5

Quote:
Originally Posted by thefatshizms
Посмотреть сообщение
Sorry ive just woken up and not thinking good yet i forgot to post that i had errors with it
Код:
C:\Users\iphone\Desktop\Pawn Scripting\gamemodes\Sfcnr.pwn(2435) : error 001: expected token: "*then", but found ")"
C:\Users\iphone\Desktop\Pawn Scripting\gamemodes\Sfcnr.pwn(2435) : error 029: invalid expression, assumed zero
C:\Users\iphone\Desktop\Pawn Scripting\gamemodes\Sfcnr.pwn(2435) : warning 215: expression has no effect
C:\Users\iphone\Desktop\Pawn Scripting\gamemodes\Sfcnr.pwn(2435) : error 001: expected token: ";", but found "return"
C:\Users\iphone\Desktop\Pawn Scripting\gamemodes\Sfcnr.pwn(2435) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
can you show exactly what line make the problem(errors\wanrnings) ?
Reply
#6

pawn Код:
if GetPlayerWeed(playerid) < ammount) *then SendClientMessage(playerid, -1, "You do not have that much grams!");
Reply
#7

Exact same errors
p.s ive never seen *then before
Reply
#8

pawn Код:
if(GetPlayerWeed(playerid) < ammount) return SendClientMessage(playerid, -1, "You do not have that much grams!");
You forgot the ( after if.
Reply
#9

Edit:Goddamn late
Because of
This forum requires that you wait 120 seconds between posts. Please try again in 85 seconds.
-.-
Reply
#10

lolz thanks for that kindred i need to wake up :@

p.s enjoy +2rep and rudy +2rep thanks for efforts and ye i know thats sooo anoying with wait 120 seconds between posts

EDIT: damm rudy_ cant give rep i gotta spread it first xDD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)