Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- else if (str.substr(0, 7) == "/trade ") {
- bool found = false;
- string Name = str.substr(7, cch.length() - 7 - 1);
- if (((PlayerInfo*)(peer->data))->rawName == Name) {
- sendConsoleMsg(peer, "You can't trade yourself!");
- continue;
- }
- else if (((PlayerInfo*)(peer->data))->tradeSomeone) {
- sendConsoleMsg(peer, "Cancel current trade before trade other");
- continue;
- }
- if (((PlayerInfo*)(peer->data))->trdStarter == Name) {
- ENetPeer* currentPeer;
- for (currentPeer = server->peers;
- currentPeer < &server->peers[server->peerCount];
- ++currentPeer)
- {
- if (currentPeer->state != ENET_PEER_STATE_CONNECTED)
- continue;
- if (isHere(peer, currentPeer)) {
- if (((PlayerInfo*)(peer->data))->trdStarter == ((PlayerInfo*)(currentPeer->data))->rawName) {
- GamePacket pt1 = packetEnd(appendInt(appendString(appendString(createPacket(), "OnStartTrade"), ((PlayerInfo*)(currentPeer->data))->rawName), ((PlayerInfo*)(currentPeer->data))->netID));
- ENetPacket* packetw = enet_packet_create(pt1.data,
- pt1.len,
- ENET_PACKET_FLAG_RELIABLE);
- enet_peer_send(peer, 0, packetw);
- delete pt1.data;
- }
- }
- }
- continue;
- }
- ENetPeer* currentPeer;
- for (currentPeer = server->peers;
- currentPeer < &server->peers[server->peerCount];
- ++currentPeer)
- {
- if (currentPeer->state != ENET_PEER_STATE_CONNECTED)
- continue;
- if (isHere(peer, currentPeer)) {
- if (((PlayerInfo*)(currentPeer->data))->rawName == Name) {
- found = true;
- if (((PlayerInfo*)(currentPeer->data))->tradeSomeone) {
- sendConsoleMsg(peer, "That player already trade with someone else");
- continue;
- }
- GamePacket pt1 = packetEnd(appendInt(appendString(appendString(createPacket(), "OnStartTrade"), ((PlayerInfo*)(currentPeer->data))->rawName), ((PlayerInfo*)(currentPeer->data))->netID));
- ENetPacket* packetw = enet_packet_create(pt1.data,
- pt1.len,
- ENET_PACKET_FLAG_RELIABLE);
- enet_peer_send(peer, 0, packetw);
- delete pt1.data;
- }
- }
- }
- if (!found) {
- sendConsoleMsg(peer, "The player no found ");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement