SA-MP Forums Archive
Help Me in String - 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: Help Me in String (/showthread.php?tid=538721)



Help Me in String - FisherMan - 23.09.2014

Hello, Every One
Today i Try To Making Rape + Cure Command But String Error im try search there much string and i want 1 only
i have 2 problem String And KillTimer
Quote:

C:\Documents and Settings\000\My Documents\ffff\gamemodes\c.pwn(1003) : error 003: declaration of a local variable must appear in a compound block
C:\Documents and Settings\000\My Documents\ffff\gamemodes\c.pwn(1003) : error 017: undefined symbol "string"
C:\Documents and Settings\000\My Documents\ffff\gamemodes\c.pwn(1003) : warning 215: expression has no effect
C:\Documents and Settings\000\My Documents\ffff\gamemodes\c.pwn(1003) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\000\My Documents\ffff\gamemodes\c.pwn(1003) : fatal error 107: too many error messages on one line

PHP код:
CMD:rape(playeridparams[])
{
    new 
targetid;
    if(
sscanf(params"u"targetid)) return SendClientMessage(playeridCOLOR_RED"[USAGE]: /rape [Part of Name/Player ID]");
    new 
Float:xFloat:yFloat:z;
    
GetPlayerPos(playeridxyz);
    if(
IsPlayerInRangeOfPoint(targetid5.0xyz))
    new 
string[500];
    
SetPlayerHealth(playerid, -7);
    new 
playerid[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    new 
targetid[MAX_PLAYER_NAME];
    
format(strsizeof(str), "INFO: You have rape %s!",target);
    
PlayerTimer[targetid] = SetTimerEx("Rape",3000,true,"i",targetid);
    return 
1;
}
CMD:cure(playeridparams[])
{
    new 
targetid;
    if(
sscanf(params"u"targetid)) return SendClientMessage(playeridCOLOR_RED"[USAGE]: /cure [Part of Name/Player ID]");
    new 
string[500];
    new 
targetid[MAX_PLAYER_NAME];
    
KillTimer(Rape[playerid]);
    
SetPlayerHealth(playerid100);
    return 
1;

i try making kill timer on player death -health to stop but i get it error i making in 3 sec health -7 in 3 sec
please help me in string and kill timer thanks
PHP код:
forward Rape(playerid);
public 
Rape(playerid)
{
    
SetPlayerHealth(playerid0);
    
KillTimer(Rape[playerid]);
    return 
1;

sorry guys im bad i learn + try making code


Re: Help Me in String - Sascha - 23.09.2014

pawn Код:
new targetid[MAX_PLAYER_NAME];
    format(str, sizeof(str, "INFO: You have rape %s!",target);
should be
pawn Код:
new target[MAX_PLAYER_NAME];
GetPlayerName(targetid, target, sizeof(target));
format(string, sizeof(string), "You have raped %s", target);



Re: Help Me in String - FisherMan - 23.09.2014

Quote:

C:\Documents and Settings\NightDay\My Documents\ffff\gamemodes\c.pwn(1003) : error 003: declaration of a local variable must appear in a compound block
C:\Documents and Settings\1\My Documents\ffff\gamemodes\c.pwn(1003) : error 017: undefined symbol "string"
C:\Documents and Settings\1\My Documents\ffff\gamemodes\c.pwn(1003) : warning 215: expression has no effect
C:\Documents and Settings\1\My Documents\ffff\gamemodes\c.pwn(1003) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\1\My Documents\ffff\gamemodes\c.pwn(1003) : fatal error 107: too many error messages on one line

This String Error
line 1003=
Quote:

new string[500];




Re: Help Me in String - FisherMan - 23.09.2014

Quote:
Originally Posted by Sascha
Посмотреть сообщение
pawn Код:
new targetid[MAX_PLAYER_NAME];
    format(str, sizeof(str, "INFO: You have rape %s!",target);
should be
pawn Код:
new target[MAX_PLAYER_NAME];
GetPlayerName(targetid, target, sizeof(target));
format(string, sizeof(string), "You have raped %s", target);
String its all problems
Any One Help Me +Rep


Re: Help Me in String - XStormiest - 23.09.2014

pawn Код:
CMD:rape(playerid, params[])
{
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "[USAGE]: /rape [Part of Name/Player ID]");
    new Float:x, Float:y, Float:z;
    GetPlayerPos(targetid, x, y, z);
    if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z)) {
    new string[500];
    SetPlayerHealth(playerid, 0);
    new target[MAX_PLAYER_NAME];
    GetPlayerName(targetid, target, sizeof(target));
    format(string, sizeof(string), "INFO: You have rape %s!",target);
    PlayerTimer[targetid] = SetTimerEx("Rape",3000,true,"i",targetid); }
    else SendClientMessage(playerid, COLOR_RED, "Your message here if player is not near target!");
    return 1;
}
CMD:cure(playerid, params[])
{
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "[USAGE]: /cure [Part of Name/Player ID]");
    KillTimer(Rape[targetid]);
    SetPlayerHealth(targetid, 100);
    return 1;
}
Wow,... so many bad things I've seen there.
Try this one.

Just say if you have more problems, These are just some fews I managed to see and quicly fix them.

EDIT: I did many edits, as I saw more and more mistakes, hope this will work now.


Re: Help Me in String - FisherMan - 23.09.2014

Quote:
Originally Posted by XStormiest
Посмотреть сообщение
pawn Код:
CMD:rape(playerid, params[])
{
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "[USAGE]: /rape [Part of Name/Player ID]");
    new Float:x, Float:y, Float:z;
    GetPlayerPos(targetid, x, y, z);
    if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z)) {
    new string[500];
    SetPlayerHealth(playerid, 0);
    new target[MAX_PLAYER_NAME];
    GetPlayerName(targetid, target, sizeof(name));
    format(string, sizeof(string), "INFO: You have rape %s!",target);
    PlayerTimer[targetid] = SetTimerEx("Rape",3000,true,"i",targetid); }
    else SendClientMessage(playerid, COLOR_RED, "Your message here if player is not near target!");
    return 1;
}
CMD:cure(playerid, params[])
{
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "[USAGE]: /cure [Part of Name/Player ID]");
    KillTimer(Rape[targetid]);
    SetPlayerHealth(targetid, 100);
    return 1;
}
Wow,... so many bad things I've seen there.
Try this one.

Just say if you have more problems, These are just some fews I managed to see and quicly fix them.

EDIT: I did many edits, as I saw more and more mistakes, hope this will work now.
Quote:

C:\Documents and Settings\NightDay\My Documents\ffff\gamemodes\c.pwn(1006) : error 017: undefined symbol "name"
C:\Documents and Settings\0\My Documents\ffff\gamemodes\c.pwn(1006) : error 029: invalid expression, assumed zero
C:\Documents and Settings\0\My Documents\ffff\gamemodes\c.pwn(1006) : warning 215: expression has no effect
C:\Documents and Settings\0\My Documents\ffff\gamemodes\c.pwn(1016) : error 028: invalid subscript (not an array or too many subscripts): "Rape"
C:\Documents and Settings\0\My Documents\ffff\gamemodes\c.pwn(1016) : warning 215: expression has no effect
C:\Documents and Settings\0\My Documents\ffff\gamemodes\c.pwn(1016) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\0\My Documents\ffff\gamemodes\c.pwn(1016) : error 029: invalid expression, assumed

so many errors now


Re: Help Me in String - XStormiest - 23.09.2014

Try this
pawn Код:
CMD:rape(playerid, params[])
{
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "[USAGE]: /rape [Part of Name/Player ID]");
    new Float:x, Float:y, Float:z;
    GetPlayerPos(targetid, x, y, z);
    if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z)) {
    new string[500];
    SetPlayerHealth(playerid, 0);
    new target[MAX_PLAYER_NAME];
    GetPlayerName(targetid, target, sizeof(target));
    format(string, sizeof(string), "INFO: You have rape %s!",target);
    PlayerTimer[targetid] = SetTimerEx("Rape",3000,true,"i",targetid); }
    else SendClientMessage(playerid, COLOR_RED, "Your message here if player is not near target!");
    return 1;
}
CMD:cure(playerid, params[])
{
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "[USAGE]: /cure [Part of Name/Player ID]");
    KillTimer(Rape[targetid]);
    SetPlayerHealth(targetid, 100);
    return 1;
}
I did something wrong with
Код:
    GetPlayerName(targetid, target, sizeof(target));
As you can see all errors now come from a single line: 1006 wich was the one above, try the new code.
thats why it gave those errors, but now is fixed xD


Re: Help Me in String - FisherMan - 23.09.2014

Quote:

C:\Documents and Settings\NightDay\My Documents\ffff\gamemodes\c.pwn(1016) : error 028: invalid subscript (not an array or too many subscripts): "Rape"
C:\Documents and Settings\g\My Documents\ffff\gamemodes\c.pwn(1016) : warning 215: expression has no effect
C:\Documents and Settings\j\My Documents\ffff\gamemodes\c.pwn(1016) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\d\My Documents\ffff\gamemodes\c.pwn(1016) : error 029: invalid expression, assumed zero
C:\Documents and Settings\g\My Documents\ffff\gamemodes\c.pwn(1016) : fatal error 107: too many error messages on one line

1016=
Quote:

KillTimer(Rape[targetid]);




Re: Help Me in String - XStormiest - 23.09.2014

pawn Код:
CMD:cure(playerid, params[])
{
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "[USAGE]: /cure [Part of Name/Player ID]");
    KillTimer(Rape[targetid]);
    SetPlayerHealth(targetid, 100);
    return 1;
}
hmmm... not an array?
according tot the script: Rape should be a global variable and also should be like
Код:
new Rape[MAX_PLAYERS];



Re: Help Me in String - FisherMan - 23.09.2014

wtf
Quote:

C:\Documents and Settings\a\My Documents\ffff\gamemodes\c.pwn(82 : error 021: symbol already defined: "Rape"
C:\Documents and Settings\s\My Documents\ffff\gamemodes\c.pwn(829) : error 021: symbol already defined: "Rape"
C:\Documents and Settings\d\My Documents\ffff\gamemodes\c.pwn(833) : error 010: invalid function or declaration

Quote:

forward Rape(playerid);
public Rape(playerid)
{
SetPlayerHealth(playerid, 0);
KillTimer(Rape[targetid]);
return 1;
}

this line error