Set Score Command
#1

Guyz Can Anyone Help Me ? I Got A Problem This Is The Code I Use

Code:
if(strcmp(cmd, "/setscore", true) == 0)
    {
    new sendername[MAX_PLAYER_NAME];
    new tmp[256];
    new tmp2[256];
    tmp = strtok(cmdtext, idx);
    new givenplayer = strval(tmp);
    tmp2 = strtok(cmdtext, idx);
    new score = strval(tmp2);
    if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setscore [playerid] [Score]");
    if(!IsPlayerConnected(otherplayer)) return SendClientMessage(playerid, COLOR_WHITE, "Invaild player ID!");
    SetPlayerScore(givenplayer,score);
    GetPlayerName(playerid, sendername, sizeof(sendername));
    format(string, sizeof(string), "Admin \"%s\" has just set your score to %d!", sendername, score);
    SendClientMessage(otherplayer, COLOR_GREEN, string);
    return 1;
    }
And It Shows This Error:
Code:
C:\Users\GMZeus\Desktop\Clean\gamemodes\XS.pwn(7127) : error 017: undefined symbol "otherplayer"
C:\Users\GMZeus\Desktop\Clean\gamemodes\XS.pwn(7130) : error 017: undefined symbol "string"
C:\Users\GMZeus\Desktop\Clean\gamemodes\XS.pwn(7130) : error 017: undefined symbol "string"
C:\Users\GMZeus\Desktop\Clean\gamemodes\XS.pwn(7130) : error 029: invalid expression, assumed zero
C:\Users\GMZeus\Desktop\Clean\gamemodes\XS.pwn(7130) : fatal error 107: too many error messages on one line

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


5 Errors.
Can Anyone Help Me Pls? Urgent
Reply
#2

for these kind of CMDs i refer you to use zcmd
pawn Code:
CMD:setscore(playerid, params[])
{
    new targetid, score, sendername[MAX_PLAYER_NAME], receivername[MAX_PLAYER_NAME], string[128];
     if(!IsPlayerAdmin(playerid)) return 0;
    if(sscanf(params,"ui", targetid, score)) return SendClientMessage(playerid, 0xFFFFFFF, "USAGE: /SetScore [PlayerID] [Score]");
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, red, "Error: Your not Admin!");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, red, "Error: This Player isnt Connected!");
    GetPlayerName(playerid, sendername, sizeof(sendername));
    GetPlayerName(targetid, receivername,sizeof(receivername));
    format(string, sizeof(string),"Your Score been setted to %d by admin %s", score, sendername);
    SendClientMessage(targetid, 0xFFFFFF, string);
    format(string, sizeof(string),"Admin %s Setted your score to %d", receivername, score);
    SendClientMessage(targetid, sand, string);
    SetPlayerScore(playerid, score);
    return 1;
}
Reply
#3

I Am Not Good Enough At CMD Can u Pls Help Me?
Reply
#4

You haven't defined "otherplayer" and "string" ... It can't be any more obvious than this.
Reply
#5

Can Anyone Teamviewer me Pls?

Username: 870 752 264
Password: 46h1cc

I Am Just A Begginer
Reply
#6

as king told you add those
pawn Code:
new string[128], otherplayerid;
under
pawn Code:
new sendername[MAX_PLAYER_NAME];
    new tmp[256];
    new tmp2[256];
Reply
#7

Quote:
Originally Posted by xMCx
View Post
as king told you add those
pawn Code:
new string[128], otherplayerid;
under
pawn Code:
new sendername[MAX_PLAYER_NAME];
    new tmp[256];
    new tmp2[256];
I Already Put Under

New Error

Code:
C:\Users\GMZeus\Desktop\Clean\gamemodes\XS.pwn(7129) : error 017: undefined symbol "otherplayer"
C:\Users\GMZeus\Desktop\Clean\gamemodes\XS.pwn(7133) : error 017: undefined symbol "otherplayer"
C:\Users\GMZeus\Desktop\Clean\gamemodes\XS.pwn(7123) : warning 203: symbol is never used: "otherplayerid"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#8

There you go, change the colors if you want, and remove the includes and stuff if your already have it.

pawn Code:
#include <a_samp>
#include <zcmd>
#include <sscanf>
CMD:setscore(playerid, params[])
{
    new sand;
    new targetid, score, sendername[MAX_PLAYER_NAME], receivername[MAX_PLAYER_NAME], string[128];
    if(!IsPlayerAdmin(playerid)) return 0;
    if(sscanf(params,"ui", targetid, score)) return SendClientMessage(playerid, 0xFFFFFFF, "USAGE: /SetScore [PlayerID] [Score]");
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFFF, "Error: Your not Admin!");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFFFFFFF, "Error: This Player isnt Connected!");
    GetPlayerName(playerid, sendername, sizeof(sendername));
    GetPlayerName(targetid, receivername,sizeof(receivername));
    format(string, sizeof(string),"Your Score been setted to %d by admin %s", score, sendername);
    SendClientMessage(targetid, 0xFFFFFF, string);
    format(string, sizeof(string),"Admin %s Setted your score to %d", receivername, score);
    SendClientMessage(targetid, sand, string);
    SetPlayerScore(playerid, score);
    return 1;
}
Reply
#9

gnoomen2 My Problem is i cant and i am a beginner still dont know how to insert these? can you help me? or teamviewer for fast? plssss
Reply
#10

Try this: replace:
pawn Code:
if(strcmp(cmd, "/setscore", true) == 0)
    {
    new sendername[MAX_PLAYER_NAME];
    new tmp[256];
    new tmp2[256];
    tmp = strtok(cmdtext, idx);
    new givenplayer = strval(tmp);
    tmp2 = strtok(cmdtext, idx);
    new score = strval(tmp2);
    if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setscore [playerid] [Score]");
    if(!IsPlayerConnected(otherplayer)) return SendClientMessage(playerid, COLOR_WHITE, "Invaild player ID!");
    SetPlayerScore(givenplayer,score);
    GetPlayerName(playerid, sendername, sizeof(sendername));
    format(string, sizeof(string), "Admin \"%s\" has just set your score to %d!", sendername, score);
    SendClientMessage(otherplayer, COLOR_GREEN, string);
    return 1;
    }
With this:
pawn Code:
if(strcmp(cmd, "/setscore", true) == 0)
{
    new sand;
    new targetid, score, sendername[MAX_PLAYER_NAME], receivername[MAX_PLAYER_NAME], string[128];
    if(!IsPlayerAdmin(playerid)) return 0;
    if(sscanf(params,"ui", targetid, score)) return SendClientMessage(playerid, 0xFFFFFFF, "USAGE: /SetScore [PlayerID] [Score]");
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFFF, "Error: Your not Admin!");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFFFFFFF, "Error: This Player isnt Connected!");
    GetPlayerName(playerid, sendername, sizeof(sendername));
    GetPlayerName(targetid, receivername,sizeof(receivername));
    format(string, sizeof(string),"Your Score been setted to %d by admin %s", score, sendername);
    SendClientMessage(targetid, 0xFFFFFF, string);
    format(string, sizeof(string),"Admin %s Setted your score to %d", receivername, score);
    SendClientMessage(targetid, sand, string);
    SetPlayerScore(playerid, score);
    return 1;
}
If you get errors after replacing thorse try to post them here and we can see if we can fix them, i think this should work, and on top of your game mode search for #include <sscanf> if you don't have that you must add #include <sscanf> below #include <a_samp> but you must download the sscanf include and put it in pawno/includes folder.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)