PDA

View Full Version : [HELP] Script failing a lot.


G6X
18/06/2012, 10:07 AM
Hi there!

A guy Kindred scripted a cmd for me, the code is:
CMD:rape(playerid, params[])
{
new targetid;
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "Usage: /rape [playerid]");
else if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "Invalid player specified.");
else if(targetid == playerid) return SendClientMessage(playerid, -1, "You can't rape yourself!");
new success = random(4);
if(success == 1)
{
new Float:oldhealth, Float:oldx, Float:oldy, Float:oldz;
GetPlayerHealth(targetid, oldhealth);
SetPlayerHealth(targetid, oldhealth - 20);
PlayerPlaySound(targetid,1190,0.0,0.0,0.0);
GetPlayerPos(targetid, oldx, oldy, oldz);
SetPlayerPos(targetid, oldx, oldy, oldz + 3);
}
new fail = random(4);
if(fail ==2)
{
SendClientMessage(playerid,-1,"The person got away, you've failed to rape him");
}
return 1;
}

I did last part , "The Person got away, you've failed to rape him"

Ok so, first to start off
When i successfully rape a guy it says this msg too "The person got away blah blah"
The code that KindRed provided which i've appriciated a lot has few problems too
Main one
The messages
"You can't rape yourself!"
"Invalid player specified."
Do not APPEAR in chat.

Also if anyone can script and fix this so
- You can not rape a player from a car, you need to be on foot
- You can not rape the player twice, you need to rape some other guy first to again rape him, which will be in beetwen 1min every rape attempt you can do :P
- I can rape a guy 100 times in a row , i need a timer of 1 minute in beetwen every rape

P.S: I'm a noob at pawn, i'm learning it tho from time to time. :)

Thanks a lot!
Regards!

[MM]RoXoR[FS]
18/06/2012, 10:38 AM
Try this..
It is untested.

On The Top

#include <a_samp>
#include <sscanf2>
#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
#define red 0xFF0000FF




enum RapeSystem
{
JustRaped,
}

new Rape[MAX_PLAYERS][RapeSystem];



public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(rape,4,cmdtext);
return 0;
}


Code for rape

dcmd_rape(playerid,params[])
{
new targetid;
if(sscanf(params,"u",targetid)) return SendClientMessage(playerid,red,"USAGE : /rape [playerid]");
else if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,red,"Player is not connected.");
else if(targetid == playerid) return SendClientMessage(playerid, red, "You can't rape yourself!");
else if(Rape[playerid][JustRaped] == targetid) return SendClientMessage(playerid, red, "You can not rape this person until 1 min have passed.");
else if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, red, "You can not rape from inside a car.");
new success = random(4);
if(success == 1)
{
new Float:oldhealth, Float:oldx, Float:oldy, Float:oldz;
GetPlayerHealth(targetid, oldhealth);
SetPlayerHealth(targetid, oldhealth - 20);
PlayerPlaySound(targetid,1190,0.0,0.0,0.0);
GetPlayerPos(targetid, oldx, oldy, oldz);
SetPlayerPos(targetid, oldx, oldy, oldz + 3);
Rape[playerid][JustRaped] = targetid;
SetTimerEx("RapeAgain",60000,false,"i",playerid);
}
else return SendClientMessage(playerid,red,"The person got away, you've failed to rape him");

return 1;
}


And Now for timer

forward RapeAgain(playerid);
public RapeAgain(playerid)
{
Rape[playerid][JustRaped] = -1;
return 1;
}

Chris1337
20/06/2012, 12:13 AM
#include <a_samp>
#include <sscanf2>
#include <zcmd>

forward rapeagain(playerid, target);
new target;
new raped[MAX_PLAYERS]; /// Defining The Recently Raped People
new rapist[MAX_PLAYERS]; /// If His Dick still Hurts

command(rape, playerid, params[])//Command
{
if(sscanf(params, "u", target)) SendClientMessage(playerid, -1, "Usage: /rape [playerid]");
if(!IsPlayerConnected(target)) SendClientMessage(playerid, -1, "Invalid player specified.");
if(IsPlayerInAnyVehicle(target)) SendClientMessage(playerid, -1, "The Player Is In A Vehicle");
if(rapist[playerid] == 1) SendClientMessage(playerid, -1, "Your Dick Still Hurts From Last Rape.");
if(target == playerid) SendClientMessage(playerid, -1, "You can't rape yourself!");
new odds = random(4);
if(odds == 1)
{
if(raped[target] == 0)
{
new Float:oldhealth, Float:oldx, Float:oldy, Float:oldz, name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME], strings[100];
GetPlayerHealth(target, oldhealth);
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(target, name2, sizeof(name2));
SetPlayerHealth(target, oldhealth - 20);
PlayerPlaySound(target,1190,0.0,0.0,0.0);
GetPlayerPos(target, oldx, oldy, oldz);
SetPlayerPos(target, oldx, oldy, oldz + 3);
format(strings, sizeof(strings), "%s(%i) Has Raped You", name, playerid);
SendClientMessage(target, -1, strings);
format(strings, sizeof(strings), "You Raped %s(%i)", name2, target);
SendClientMessage(playerid, -1, strings);
SetTimerEx("rapeagain",60000,false,"ii",playerid, target);

rapist[playerid] = 1;
raped[target] = 1;
}
if(raped[target] == 0)
{
SendClientMessage(playerid,-1,"He Has Been Raped Recently");
}
}
if(odds == 0 || odds == 2 || odds == 3 || odds == 4)
{
SendClientMessage(playerid,-1,"The person got away, you've failed to rape him");
}
return 0;
}

public rapeagain(playerid, target)
{
rapist[playerid] = 0;
raped[target] = 0;
return 1;
}


There it is with ZCMD (havent tested it) but i think works fine

PD: Why you add another random


new fail = random(4);


That way you create 1 odd but if in one goes to 4 and other to 3 , will be weird

G6X
20/06/2012, 11:25 AM
@ public rapeagain(playerid, target)
{
rapist[playerid] = 0;
raped[target] = 0;
return 1;
}
C:\Users\Daniel\Desktop\samp03e_svr_win32\gamemode s\hooligansdm.pwn(1215) : warning 219: local variable "target" shadows a variable at a preceding level


My friend Daniel tried to export and got this error. ^

Revo
20/06/2012, 11:34 AM
x.o


CMD:rape(playerid, params[])
{
new targetid;
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "Usage: /rape [playerid]");
else if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "Invalid player specified.");
else if(targetid == playerid) return SendClientMessage(playerid, -1, "You can't rape yourself!");
new success = random(4);
if(succes <= 3)
{
new Float:oldhealth, Float:oldx, Float:oldy, Float:oldz;
GetPlayerHealth(targetid, oldhealth);
SetPlayerHealth(targetid, oldhealth - 20);
PlayerPlaySound(targetid,1190,0.0,0.0,0.0);
GetPlayerPos(targetid, oldx, oldy, oldz);
SetPlayerPos(targetid, oldx, oldy, oldz + 3);
}
else {
SendClientMessage(playerid,-1,"The person got away, you've failed to rape him");
}
return 1;
}

Chris1337
20/06/2012, 04:20 PM
@ public rapeagain(playerid, target)
{
rapist[playerid] = 0;
raped[target] = 0;
return 1;
}
C:\Users\Daniel\Desktop\samp03e_svr_win32\gamemode s\hooligansdm.pwn(1215) : warning 219: local variable "target" shadows a variable at a preceding level


My friend Daniel tried to export and got this error. ^


Its a warning , its not an error , actually has nothing to do with it